7 Reasons Why You Should Keep Learning C/C++
Many programmers are frustrated with and leaning away toward the C/C++ programming languages because of the following reasons: (1) Very steep learning curve.. Many people joined the programming world by learning C or C++, but it’s rare for them to keep learning and mastering these two languages well because they get frustrated in handling the low-level programming elements such as pointers, the memory storage model, address alignment, templates expansion, multi-thread data races, and so on. If these elements are not handled properly, the app will have a high probability of crashing, which will frustrate the new programmer. (2) Rarely used in modern application development Nowadays we have many advanced programming languages like Java, C#, Python, Javascript, Go, etc for application development and it seems insane if someone wanted to develop a Web application or backend service in pure C/C++. The common application areas have been taken over by more advanced programming languages such as: Web front-end development: Javascript/Typescript rule everything and the three popular frameworks in frontend are Angular, React, and Vue. Web back-end service development: Javascript (Node), Python (Flask, Django), Java, and PHP are the popular technologies used. Desktop application development: QT (PyQT, C++), Electron (Javascript), WPF (C#). Mobile application development: iOS (Objective-C, Swift), Android (Java). Distributed systems, Big Data, Cloud Computing: Java, Go, Groovy, Scala. Data science, AI (Artificial Intelligence), ML (Machine Learning): Python. It looks like C/C++ are rarely used in these modern application development areas. So why should we still learn C/C++? Here are 7 reasons why you should: https://simpliv.wordpress.com/2019/08/06/7-reasons-why-you-should-keep-learning-c-c/ -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
On 06Aug2019 00:01, Jonathan Moules wrote: Some gotcha tips from using SQLite with Python that I've encountered. [...] * To be reliably INSERTed Byte data should be first converted to sqlite3.Binary(my_data) explicitly Interesting. Is that Python 2 specific, or also in Python 3. Because the latter would surprise me (not saying it isn't the case). * It's typically opaque as to where the install of SQLite is that the library is using and it's very hard and not-documented as to how to update the SQLite version that Python is using. On a UNIX system the command "lsof -p pid-of-running-python-process" should show the path of the sqlite library that is linked to the Python executable, which should let you learn this. If you want an even thinner wrapper around SQLite there's APSW ( https://rogerbinns.github.io/apsw/index.html ) - I've never used it myself but it's useful to know about. There's a page with differences - https://rogerbinns.github.io/apsw/pysqlite.html#pysqlitediffs And for a thicker wrapper, I've been extremely happy using SQLAlchemy for database access. It has an expression syntax where real Python expressions (containing "column" objects) evaluate to safe SQL, letting you write safe queries in nice Pythonic form, and it also has an ORM for more sophisticated use. It provided context manager for transactions and sessions for various work. Finally, it knows about a lot of backends, so you could switch backends later (eg from SQLite to PostgreSQL) if that becomes a thing. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
Some gotcha tips from using SQLite with Python that I've encountered. You may already know some/all of these: * SQLite doesn't have a "Truncate" function - simply delete the file if possible for larger datasets. * Explicitly committing is good because the default python sqlite3 library does it randomly and implicitly. I found that doing it only when the database is dettaching or closing speeds things up a lot. * SQLite 3 only considers up to 64bits an INTEGER. So if you want to insert a 128bit string you have to use Python string substitution (i.e. "Hello %s") rather than the SQLite variable substitution "insert into tab values (?)" * To be reliably INSERTed Byte data should be first converted to sqlite3.Binary(my_data) explicitly * By default Foreign Keys are not enforced. Enable them at connection time if you care about referential integrity! * It's typically opaque as to where the install of SQLite is that the library is using and it's very hard and not-documented as to how to update the SQLite version that Python is using. If you want an even thinner wrapper around SQLite there's APSW ( https://rogerbinns.github.io/apsw/index.html ) - I've never used it myself but it's useful to know about. There's a page with differences - https://rogerbinns.github.io/apsw/pysqlite.html#pysqlitediffs On 2019-08-05 22:43, David Raymond wrote: "What's the advantage of this over letting the connection object do that for you? As the context manager exits, it will automatically either commit or roll back. If you want to guarantee closing _as well_, then you can do that, but you can at least use what already exists." After review I guess I should have phrased it more as a "here's what I've found for reference" rather than a "here's what _you_ should do" Part of it is large use of the Command Line Interface for SQLite, and similar command line tools for other db's, which all work in autocommit mode by default, so that's how my brain is now wired to think about executing things. The context manager transaction feature I can see using, and might actually start switching to it as it's explicit enough. Though oddly, __enter__ doesn't seem to actually begin a transaction, not even a deferred one. It's only __exit__ that either commits or rolls back. (Eh, it'd "probably" be simple enough to subclass Connection so that __enter__ and __exit__ work properly no matter the isolation_level. Famous last words) The implicit stuff I hated because it never seemed straightforward enough. Especially since there used to be implicit commits as well as implicit begins ("Changed in version 3.6: sqlite3 used to implicitly commit an open transaction before DDL statements. This is no longer the case.") Maybe because I was new to both Python and SQLite at the time, but there was a lot of "stop doing hidden stuff I didn't tell you do" getting muttered, along with others like "why do I need to commit when I never did a begin?" The documentation on it is all of 1 sentence, so there was a lot of trial an error going on. "The Python sqlite3 module by default issues a BEGIN statement implicitly before a Data Modification Language (DML) statement (i.e. INSERT/UPDATE/DELETE/REPLACE)." "(Also, I'd definitely use conn.commit() rather than cur.execute("commit"), in case there's extra functionality in the commit method.)" True. I know for example that if you try to rollback when not in a transaction that cur.execute("rollback;") will raise an exception whereas conn.rollback() will quietly suppress it for you. So there might be similarly useful stuff in .commit() sqlite3 is (almost) all C though, so there'd be noticeably more digging and decyphering required to check. (For me anyway) -- https://mail.python.org/mailman/listinfo/python-list
Re: Please help me
On 2019-08-05 17:40, arash kohansal wrote: Hello ive just installed python on my pc and ive already check the path choice part but microsoft visual code can not find it and it does not have the reload item 1. Open Visual Studio Code. 2. Press F1, type "Python: Select Interpreter", and then press Enter. 3. Select the Python version that you installed from the list. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
On Tue, Aug 6, 2019 at 7:45 AM David Raymond wrote: > The context manager transaction feature I can see using, and might actually > start switching to it as it's explicit enough. Though oddly, __enter__ > doesn't seem to actually begin a transaction, not even a deferred one. It's > only __exit__ that either commits or rolls back. > (Eh, it'd "probably" be simple enough to subclass Connection so that > __enter__ and __exit__ work properly no matter the isolation_level. Famous > last words) > Easier just to leave the isolation level and let it automatically begin. (This is another reason to use the commit and rollback methods, as they may flag the connection as "hey, remember to begin before the next query".) > The implicit stuff I hated because it never seemed straightforward enough. > Especially since there used to be implicit commits as well as implicit begins > ("Changed in version 3.6: sqlite3 used to implicitly commit an open > transaction before DDL statements. This is no longer the case.") Maybe > because I was new to both Python and SQLite at the time, but there was a lot > of "stop doing hidden stuff I didn't tell you do" getting muttered, along > with others like "why do I need to commit when I never did a begin?" The > documentation on it is all of 1 sentence, so there was a lot of trial an > error going on. > I grew up on DB2 5.0 (after working in PC File and dbase), and you never did a BEGIN TRANSACTION unless you wanted to set specific parameters, but always had to COMMIT/ROLLBACK. The database itself would automatically open a transaction as soon as you do any query, and leave it open till you're done. So to me, that was never a problem. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
RE: Python/SQLite best practices
"What's the advantage of this over letting the connection object do that for you? As the context manager exits, it will automatically either commit or roll back. If you want to guarantee closing _as well_, then you can do that, but you can at least use what already exists." After review I guess I should have phrased it more as a "here's what I've found for reference" rather than a "here's what _you_ should do" Part of it is large use of the Command Line Interface for SQLite, and similar command line tools for other db's, which all work in autocommit mode by default, so that's how my brain is now wired to think about executing things. The context manager transaction feature I can see using, and might actually start switching to it as it's explicit enough. Though oddly, __enter__ doesn't seem to actually begin a transaction, not even a deferred one. It's only __exit__ that either commits or rolls back. (Eh, it'd "probably" be simple enough to subclass Connection so that __enter__ and __exit__ work properly no matter the isolation_level. Famous last words) The implicit stuff I hated because it never seemed straightforward enough. Especially since there used to be implicit commits as well as implicit begins ("Changed in version 3.6: sqlite3 used to implicitly commit an open transaction before DDL statements. This is no longer the case.") Maybe because I was new to both Python and SQLite at the time, but there was a lot of "stop doing hidden stuff I didn't tell you do" getting muttered, along with others like "why do I need to commit when I never did a begin?" The documentation on it is all of 1 sentence, so there was a lot of trial an error going on. "The Python sqlite3 module by default issues a BEGIN statement implicitly before a Data Modification Language (DML) statement (i.e. INSERT/UPDATE/DELETE/REPLACE)." "(Also, I'd definitely use conn.commit() rather than cur.execute("commit"), in case there's extra functionality in the commit method.)" True. I know for example that if you try to rollback when not in a transaction that cur.execute("rollback;") will raise an exception whereas conn.rollback() will quietly suppress it for you. So there might be similarly useful stuff in .commit() sqlite3 is (almost) all C though, so there'd be noticeably more digging and decyphering required to check. (For me anyway) -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On Tue, Aug 6, 2019 at 7:09 AM DL Neil wrote: > As a matter of interest (and if you don't mind sharing), which packages > are included in the organisation's student "stack"? > (again: no 'judgement', please) TBH the best stack I can describe is what we teach for JavaScript students, as they're the ones who have the bootcamp format (although that's now changing, as we have a data science bootcamp built on Python - but I don't know whether the tech stack has been settled yet). We get them to use VS Code, ESLint, Node.js, npm, git, PostgreSQL (once they get to that point), and a handful of JavaScript libraries/packages. > How 'expensive' or distracting is it, merely in terms of trainees > failing to follow the installation/configuration instructions? Not too bad; there's some cost when someone has trouble setting up eslint, or when their editor's indentation settings don't match the linter's, but it's manageable. > Do you find 'my first program' (when trainees are first required to use > the 'stack') to be a major failure/frustration/drop-out point? To what > degree might that be caused by the trainee realising that (s)he has to > turn 'book knowledge' into coding-action, ie 'the real world', and how > much might be the 'cost' of those tools? No, but I think the level of pressure in a bootcamp tends to lead to people just blindly accepting what they're given, rather than objecting to it. "You want me to use VS Code? Okay, no prob, what do I click on?". There isn't time to debate it, because within the next three hours, there are about eight hours' worth of work to be done :) Things would be different in other contexts. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 6/08/19 12:04 AM, Chris Angelico wrote: On Mon, Aug 5, 2019 at 8:54 PM DL Neil wrote: On 3/08/19 5:50 PM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 3:36 PM DL Neil wrote: On 3/08/19 4:02 PM, Terry Reedy wrote: ... Sometimes there can be magical firewall penetration tricks that allow the traffic to go peer-to-peer after an initial handshake with some central server, but this has its own problems. On any network that I control, such tricks are disabled; if you want to listen to connections from the outside world, you get my explicit permission and an actual line in the firewall configs. Here is the point where I'll bow-out. This sort of stuff is what NetAdmins are for! Better minds than mine... Also, there are scenarios when both (of the pair) might be contributing by 'coding' concurrently, eg one writing tests and the other code, or one writing one class and the other a second. (but you can debate if that is "pair-programming") No, that's not pair programming. That's collaboration on a project, but it's not the sort of thing where you need to see the other person's screen. Agreed. "Pair-programming" seemed the closest, commonly-used, professional term to describe how one might be remotely-useful (pun!?) during the PUG's Coding Evening. It seems reasonable that if folk are working-together yet on separate components, when they link the two components, both being able to see 'the same thing' would be a natural approach, eg one writing the tests and another the code - what happens when the tests run? Anyway, this PUG mtg is going to be an 'experience'. (I'll try (almost) anything once!) ... Is it acceptable to train folk to code (in a particular language) without also covering the likely tools they will (also) use? So with Python, during the first lesson we could jump straight into a one-line print( "hello world" ) program using the REPL. However, an editor will be employed as soon as we want our code to persist. So should we (immediately) promote the use of a professional editor/IDE, eg PyCharm, Sublime Text, Codium, Eclipse; or a 'traditional' character editing tool, eg Vi, emacs? (please no 'religious wars' just because I mentioned both in the same sentence!) At my work, we instruct students on how to set up one particular tech stack, including an editor, linter, source control, etc, etc. We're clear with them that these are not the only options, but for the sake of bootcamp time pressures, we aren't going to show them any others. Depending on what you're trying to do, it MAY be acceptable to teach just the language. But that won't make someone employable on its own. Like everything, "it depends" :) Indeed! As a matter of interest (and if you don't mind sharing), which packages are included in the organisation's student "stack"? (again: no 'judgement', please) How 'expensive' or distracting is it, merely in terms of trainees failing to follow the installation/configuration instructions? Do you find 'my first program' (when trainees are first required to use the 'stack') to be a major failure/frustration/drop-out point? To what degree might that be caused by the trainee realising that (s)he has to turn 'book knowledge' into coding-action, ie 'the real world', and how much might be the 'cost' of those tools? -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
[no subject]
Hello i have a laptob and working with windows 10 ive installed python in my pc and ive already check the path choice pary in the installation im working with microsoft visual studio code but it cant find the python installed extention and it doesnt have the green star on the top of python language -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 6/08/19 1:43 AM, Hugh Sasse wrote: I might not have followed this thread closely enough. I remembered there is a thing called Copilot. It connects two machines so that two people can work together. https://www.copilot.com/About If this is the wrong answer, it may at least help define the negative space around what you want. Thank you Hugh. Yes, there are a few of these Copilot-style packages. The one that seems popular in 'my circle' is called TeamViewer. We will definitely offer that as an option at Wednesday's PUG mtg, and if someone requests Copilot, or similar, I'll try to adapt. No, not "negative" by any means. Many thanks! -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Please help me
Hello ive just installed python on my pc and ive already check the path choice part but microsoft visual code can not find it and it does not have the reload item -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
On Tue, Aug 6, 2019 at 5:05 AM David Raymond wrote: > I believe the default Connection context manager is set up for the context to > be a single transaction, with a commit on success or a rollback on a failure. > As far as I know it does NOT close the connection on exiting the context > manager. That only happens automatically when it's getting garbage > collected/going out of scope/correct terminology that I can't seem to > remember. > > > For transactions and general use I vastly prefer using "isolation_level = > None" when creating my connections, and then explicitly issuing all begin, > commit, and rollback commands with cur.execute("begin;"), conn.commit(), > conn.rollback() etc. > > > contextlib.closing() can be used to wrap cursors for use with with > (and also connections if they are created with isolation_level = None) > > with contextlib.closing(sqlite3.connect(fi, isolation_level = None)) as conn: > conn.row_factory = sqlite3.Row > with contextlib.closing(conn.cursor()) as cur: > cur.execute("begin;") > stuff > conn.commit() > > > > Normally though my stuff tends to look like the below (for better or for > worse): > > conn = sqlite3.connect(fi, isolation_level = None) > try: > conn.row_factory = sqlite3.Row > with contextlib.closing(conn.cursor()) as cur: > cur.execute("standalone query not needing an explicit transaction;") > stuff > cur.execute("begin;") > multiple queries that needed the explicit transaction > stuff > cur.execute("commit;") > except something bad: > blah > finally: > conn.rollback() > conn.close() > What's the advantage of this over letting the connection object do that for you? As the context manager exits, it will automatically either commit or roll back. If you want to guarantee closing _as well_, then you can do that, but you can at least use what already exists. (Also, I'd definitely use conn.commit() rather than cur.execute("commit"), in case there's extra functionality in the commit method.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
RE: Python/SQLite best practices
Not a full expert, but some notes: I believe the default Connection context manager is set up for the context to be a single transaction, with a commit on success or a rollback on a failure. As far as I know it does NOT close the connection on exiting the context manager. That only happens automatically when it's getting garbage collected/going out of scope/correct terminology that I can't seem to remember. For transactions and general use I vastly prefer using "isolation_level = None" when creating my connections, and then explicitly issuing all begin, commit, and rollback commands with cur.execute("begin;"), conn.commit(), conn.rollback() etc. contextlib.closing() can be used to wrap cursors for use with with (and also connections if they are created with isolation_level = None) with contextlib.closing(sqlite3.connect(fi, isolation_level = None)) as conn: conn.row_factory = sqlite3.Row with contextlib.closing(conn.cursor()) as cur: cur.execute("begin;") stuff conn.commit() Normally though my stuff tends to look like the below (for better or for worse): conn = sqlite3.connect(fi, isolation_level = None) try: conn.row_factory = sqlite3.Row with contextlib.closing(conn.cursor()) as cur: cur.execute("standalone query not needing an explicit transaction;") stuff cur.execute("begin;") multiple queries that needed the explicit transaction stuff cur.execute("commit;") except something bad: blah finally: conn.rollback() conn.close() -Original Message- From: Python-list On Behalf Of Dave via Python-list Sent: Monday, August 05, 2019 1:49 PM To: python-list@python.org Subject: Python/SQLite best practices I'm looking for some tips from experienced hands on on this subject. Some of the areas of interest are (feel free to add more): * Passing connections and cursors - good, bad indifferent? I try to avoid passing file handles unless necessary, so I view connections and cursors the same. Though that said, I'm not aware of any specific problems in doing so. For designs with multiple tables: * Better to pass an sql string to functions that create/add data/update/delete data and pass them to create, insert, update, delete functions; or have those functions for each table? Taking table creation for example, if there are five tables, and the sql string is passed, there would need to be six functions to do it, though the complexity of each function may be reduced a little. [table1create with sql and establishing a cursor, to table5create and then a function that executes the sql]. Best way to establish the connection and cursor, as well as close them? I have seen many ways to do this, and know that the with block can be used to create a connection and close it automatically, but the same is not true of the cursor. Also, using only a with block does not handle any errors as well as a try/with. For example: | try: | # Use with block to create connection – it will close self. | with sqlite3.connect(path) as conn: | cur = conn.cursor() | cur.execute(sql_ProjectsTable) | cur.close() | except Error as e: | print(e) What else? Dave, -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
On Mon, Aug 05, 2019 at 08:12:27PM +0200, Karsten Hilbert wrote: > Transactions involving several commands may require passing > around of connections and/or cursors, however. Among chains of python code, that is. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Re: Python/SQLite best practices
On Mon, Aug 05, 2019 at 01:49:24PM -0400, Dave via Python-list wrote: > * Passing connections and cursors - good, bad indifferent? I try to avoid > passing file handles unless necessary, so I view connections and cursors the > same. Connections may be more long-lived, per thread perhaps. Cursors would generally be throw-away. Transactions involving several commands may require passing around of connections and/or cursors, however. > Best way to establish the connection and cursor, as well as close them? I > have seen many ways to do this, and know that the with block can be used to > create a connection and close it automatically, but the same is not true of > the cursor. Also, using only a with block does not handle any errors as > well as a try/with. For example: > > | try: > | # Use with block to create connection – it will close self. > | with sqlite3.connect(path) as conn: > | cur = conn.cursor() > | cur.execute(sql_ProjectsTable) > | cur.close() > | except Error as e: > | print(e) Use of try: except: finally: may come in handy for clean closure. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list
Python/SQLite best practices
I'm looking for some tips from experienced hands on on this subject. Some of the areas of interest are (feel free to add more): * Passing connections and cursors - good, bad indifferent? I try to avoid passing file handles unless necessary, so I view connections and cursors the same. Though that said, I'm not aware of any specific problems in doing so. For designs with multiple tables: * Better to pass an sql string to functions that create/add data/update/delete data and pass them to create, insert, update, delete functions; or have those functions for each table? Taking table creation for example, if there are five tables, and the sql string is passed, there would need to be six functions to do it, though the complexity of each function may be reduced a little. [table1create with sql and establishing a cursor, to table5create and then a function that executes the sql]. Best way to establish the connection and cursor, as well as close them? I have seen many ways to do this, and know that the with block can be used to create a connection and close it automatically, but the same is not true of the cursor. Also, using only a with block does not handle any errors as well as a try/with. For example: | try: | # Use with block to create connection – it will close self. | with sqlite3.connect(path) as conn: | cur = conn.cursor() | cur.execute(sql_ProjectsTable) | cur.close() | except Error as e: | print(e) What else? Dave, -- https://mail.python.org/mailman/listinfo/python-list
Re: base = 1024 if (gnu or binary) else 1000
On 2019-08-05 16:01, Hongyi Zhao wrote: Hi, I read the source code of of `humanize/filesize.py' and find the 24 line writing as follows: base = 1024 if (gnu or binary) else 1000 It seems this is not the standard usage of if ... else Is this a variant of lambda or some others? Could you please give me some more hints? It's a "conditional expression" (also called a "ternary if") and it's mentioned in Python's documentation. In this case it does the same as: if gnu or binary: base = 1024 else: base = 1000 -- https://mail.python.org/mailman/listinfo/python-list
Re: base = 1024 if (gnu or binary) else 1000
On 05/08/2019 16:01, Hongyi Zhao wrote: Hi, I read the source code of of `humanize/filesize.py' and find the 24 line writing as follows: base = 1024 if (gnu or binary) else 1000 It seems this is not the standard usage of if ... else It's a perfectly standard conditional *expression* (see https://docs.python.org/3/reference/expressions.html#conditional-expressions), not an if *statement* at all. It's the equivalent of "?:" in C and C-like languages. In general conditional expressions look like: if else Python evaluates the . If it is true, the expression evaluates to . If it is false, it evaluates to . In this specific case, "base" is assigned 1024 if "gnu" or "binary" are true, else it is assigned 1000. -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Re: Python scripts
On 04/08/2019 10:29, Arun Kumar wrote: In python application in scripts folder files are missing then how to get those files. That depends on exactly what you mean by "files are missing". If (most likely) the application is trying to import a third party module that you don't have installed, the documentation coming with the application should tell you what to install and where to get it from. If files are genuinely missing from the script folder (wherever/whatever that is), contact the author of the application. If all else fails, read the documentation ;-) -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list
Python scripts
Dear sir In python application in scripts folder files are missing then how to get those files. -- https://mail.python.org/mailman/listinfo/python-list
base = 1024 if (gnu or binary) else 1000
Hi, I read the source code of of `humanize/filesize.py' and find the 24 line writing as follows: base = 1024 if (gnu or binary) else 1000 It seems this is not the standard usage of if ... else Is this a variant of lambda or some others? Could you please give me some more hints? Regards -- .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :. -- https://mail.python.org/mailman/listinfo/python-list
Re: Any bad patterns we can find with static analyzing
On 8/5/2019 8:11 AM, Batuhan Taskaya wrote: I am developing a project called Inspector Tiger (from monty python :)) and with that project i am trying to perform a static check over the source code to find common mistakes. If you know a common mistaken pattern, it would be really great to share it with me or implement it and PR to inspector tiger. Source: https://github.com/thg-consulting/inspectortiger Read the Python FAQ and search for documents with things like 'Python gotchas' or 'Python warts'. You can also find threads here and on Stackoverflow where the gist of a problem is using bad patterns. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
I might not have followed this thread closely enough. I remembered there is a thing called Copilot. It connects two machines so that two people can work together. I've never used it, and have no connection with the company. I remember reading about it on a page written by Joel Spolsky. https://www.copilot.com/About If this is the wrong answer, it may at least help define the negative space around what you want. Hugh -- https://mail.python.org/mailman/listinfo/python-list
Any bad patterns we can find with static analyzing
I am developing a project called Inspector Tiger (from monty python :)) and with that project i am trying to perform a static check over the source code to find common mistakes. If you know a common mistaken pattern, it would be really great to share it with me or implement it and PR to inspector tiger. Source: https://github.com/thg-consulting/inspectortiger -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On Mon, Aug 5, 2019 at 8:54 PM DL Neil wrote: > > On 3/08/19 5:50 PM, Chris Angelico wrote: > > On Sat, Aug 3, 2019 at 3:36 PM DL Neil > > wrote: > >> > >> On 3/08/19 4:02 PM, Terry Reedy wrote: > >>> Good. Master-satellite would be much easier. We added line numbers to > >>> IDLE's editor last week, so verbal feedback from satellite to master > >>> should be sufficient for many purposes. > > Elsewhere in this thread others, have been looking at NAT and broker > arrangements. It has been v.interesting to read. > > If it is a corporation's project, then this is an option. The business > of choosing ports and opening firewalls is a (?mere) matter of > standardisation and coordination. (cough, cough, mumble, mumble) > > However, if we are talking about a public product, eg TeamViewer; then > ease of operation comes to the fore. (much though I disagree with what > amounts to an abuse of port-80 - specialists trying to 'manage' Internet > traffic must really have things to say about such) > > The reason I mentioned "TeamViewer" (and A.N.Other mentioned BitTorrent) > is that client-server is so much easier to implement - even if (using > this example) the two (pair-programming) start as clients to some > central server, but later comms are 'delegated'/re-directed to become > peer-to-peer or go-direct. In the case of TV, which I use in (unpaid, > much put-upon, family - you know this song!) 'technical support' mode, > both the one seeking help and my own computer have to separately log-in > to the TV system, the second asking to connect to the first... Sometimes there can be magical firewall penetration tricks that allow the traffic to go peer-to-peer after an initial handshake with some central server, but this has its own problems. On any network that I control, such tricks are disabled; if you want to listen to connections from the outside world, you get my explicit permission and an actual line in the firewall configs. > Also, there are scenarios when both (of the pair) might be contributing > by 'coding' concurrently, eg one writing tests and the other code, or > one writing one class and the other a second. (but you can debate if > that is "pair-programming") No, that's not pair programming. That's collaboration on a project, but it's not the sort of thing where you need to see the other person's screen. > > TLS doesn't really solve this problem. If you have a single central > > server, TLS just tells you that you're talking to that server, without > > proving anything about who's on the other end. Even if you directly > > connect the two nodes, TLS wouldn't prove who that is, unless you get > > a dedicated certificate. What it *can* prove is that your data stream > > hasn't been tampered with en route, but the problem of receiving code > > from strangers is still an issue. Ultimately, pair programming depends > > on a measure of trust - you have to be confident that the person > > you're pairing with isn't going to be maliciously messing with your > > system. > > As above, using a client-server relationship, thus TLS/SSH are > relatively natural, and certainly common, components of the whole. That's fine if one end is a dedicated server. > I assume a level of trust. Why would you pair-program with someone > untrustworthy? Either you're a team or not! What about poisoning the channel externally, though? If you can't directly connect a TCP socket between the two peers, the traffic will have to go out on the internet. > Is it acceptable to train folk to code (in a particular language) > without also covering the likely tools they will (also) use? > > So with Python, during the first lesson we could jump straight into a > one-line print( "hello world" ) program using the REPL. However, an > editor will be employed as soon as we want our code to persist. So > should we (immediately) promote the use of a professional editor/IDE, eg > PyCharm, Sublime Text, Codium, Eclipse; or a 'traditional' character > editing tool, eg Vi, emacs? > (please no 'religious wars' just because I mentioned both in the same > sentence!) At my work, we instruct students on how to set up one particular tech stack, including an editor, linter, source control, etc, etc. We're clear with them that these are not the only options, but for the sake of bootcamp time pressures, we aren't going to show them any others. Depending on what you're trying to do, it MAY be acceptable to teach just the language. But that won't make someone employable on its own. Like everything, "it depends" :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 5/08/19 9:59 PM, Dennis Lee Bieber wrote: On Mon, 5 Aug 2019 18:52:14 +1200, DL Neil declaimed the following: Herewith a progress-report, and an attempt to respond to (interposed) questions:- I didn't have questions so much as just comments based on documentation... Your advice, ideas, and the effort you've invested, are greatly appreciated. Thank you! Service: There are/were two: the original Cloud9/C9, and the newer/bigger/better version since Amazon took-over. There are differences! The core of the "original" is what has been provided on the BBB (and is available via an older download page -- it WILL run on a Windows box). The "original" includes the IDE functions AND runs as the web-server. As you would expect, the newer Cloud9 is clearly superior, in function. I don't think there's a F/LOSS download though! (would be more than a slight surprise were Amazon to do so) There was a product on the original list: Koding. IIRC this is delivered as a docker module?Kubernetes. I suppose such is beyond the capacities of a BBB, even a RPi4 (USB-C confusion and higher-current demands notwithstanding)*. I don't think I'm going to find sufficient time to try that option - and offering the PUG attendees three choices now (TeamViewer, PythonAnywhere, and Cloud9) is probably more than enough and heading into 'overload' territory. That said, the idea of being able to completely control the whole service, from-soup-to-nuts, is attractive - for reasons alluded-to earlier. * was blown-away by the price/specs of the nVidia Jetson Nano (similar form-factor, SBC + add-ons), which I've been looking at for image manipulation and video editing/production. Sadly, the BBB may have 'had its day'? Now... Off to report for jury pool summons... Having an alarm go off at 0500 is obscene [my normal is 0730, second alarm at 0800, and crawl out of bed at 0900, get on computer between 1000 and 1100). The claim is that "The wheels of justice turn slowly, but grind exceedingly fine.", so please ensure that you don't fall into the machinery! Perhaps you'll be more in the mood for Robin Williams: (something like) 0300! [pronounced oh-three-hundred, ie 3am, which he described as] Oh as in: Oh my God it's early! From the movie "Good Morning Vietnam", and employing typical sardonic military humor. Another (borrowed from a British unit), which may apply well to your jury-duty is "hurry up and wait"... (hope it goes well/is not too boring!) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 4/08/19 8:20 AM, Chris Angelico wrote: On Sun, Aug 4, 2019 at 4:46 AM Terry Reedy wrote: On 8/3/2019 1:50 AM, Chris Angelico wrote: Since master and clone are copies of the same program, switching roles should be simple, and easier than trading seats. Should be indeed, though having accidentally painted myself into a corner on many occasions, I would say it's worth writing this down as a goal all the same :) +1 Done! However, I think it would be an extremely useful feature if the output from running the program could also be replicated to the other client. Let's say you're developing a Python script that connects to a database (eg psycopg2 + PostgreSQL). To run that locally, you'd need your own replica of the database, and that often means having your own credentials (ie having the script able to choose which set of credentials to use), replicating the database schema, and possibly even getting a duplicate of the current table contents. Way WAY easier to just run it on one computer and copy the output. I did not think of this scenario because I don't currently program with external libraries and DBs. Sending output seems to be a must, with running delivered code an option depending on trust and code review. It does, however, require a control message to switch incoming text from editor to shell. Rather than having such a control message, perhaps it could be possible to have any number of "target window" channels? So you could have two editor windows and a shell, or even multiple shells, if Idle can do that in one process. I'm not sure how Idle's architecture is; in my experimentation, I was only able to get a single execution window. A chat window? (yes, multiple tabs, or panels, or a floating window) An audio channel? I believe bittorrent somehow deals with the issue, but I don't know how much a broker is used after the initial seeding. I believe some player-hosted multiplayer games run peer-to-peer after the initial introduction, but I don't know for sure. Hmm, bittorrent's broker is just for finding peers - it doesn't actually transfer any content. I'm pretty sure two behind-NAT torrent clients are unable to communicate unless one of them has a port forwarded to it. Restriction to local networks might have some use. There have been programming classes where a teacher uses IDLE projected on an overhead screen. In at least some cases, a large type size (25-40) is needed. It might be nicer to deliver to each students computer. The easiest way would be to have the main Idle engine able to listen on a socket OR connect to one, and then "restricting to LAN" is simply a matter of managing it in your firewall (or, in the case of many NAT networks, simply a matter of doing nothing). The broker would be a basic echo server, and if desired, it could handle encryption (TLS). Since there would potentially be many concurrent Idle replications happening, there'd need to be some sort of "room name" or something, but it could still be very simplistic. This would be a very cool feature, especially since it could bring ultra low latency pair programming even to people on mobile connections. +1 (don't forget those of us whose "high speed broadband" still falls well short of the promised "information super highway"!) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 4/08/19 6:44 AM, Terry Reedy wrote: On 8/3/2019 1:50 AM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 3:36 PM DL Neil wrote: On 3/08/19 4:02 PM, Terry Reedy wrote: Is that really "p-p" or more "code review"? The latter. The quotes here mean "the closest I currently come to pair programming". I have often *wished* for live interaction instead. See elsewhere for suggestions of how Idle might be used for such (not merely as an 'editor' - assuming that is 'all' it is now) Since master and clone are copies of the same program, switching roles should be simple, and easier than trading seats. +1 operative words "should be"! However, I think it would be an extremely useful feature if the output from running the program could also be replicated to the other client. Let's say you're developing a Python script that connects to a database (eg psycopg2 + PostgreSQL). To run that locally, you'd need your own replica of the database, and that often means having your own credentials (ie having the script able to choose which set of credentials to use), replicating the database schema, and possibly even getting a duplicate of the current table contents. Way WAY easier to just run it on one computer and copy the output. I did not think of this scenario because I don't currently program with external libraries and DBs. Sending output seems to be a must, with running delivered code an option depending on trust and code review. It does, however, require a control message to switch incoming text from editor to shell. Watching the Cloud9 system 'paint' on one machine/browser a moment after I'd typed code using a second machine, brought me a childish delight (after all the reading, learning, and fiddling of accounts and permissions to get that far) Restriction to local networks might have some use. There have been programming classes where a teacher uses IDLE projected on an overhead screen. In at least some cases, a large type size (25-40) is needed. It might be nicer to deliver to each students computer. Disagree: there's a reason it's called the "world-wide" web! Having said that: limiting to LAN makes life SO much easier. (probably mentioned earlier/elsewhere) I *HATE* using large screens, OHP panels, video projectors, etc. Firstly, they always seem to be going wrong - the problem of too many 'moving parts'. Recently I was asked to give a user-oriented course in DB retrieval (cf programmers using SQL). I decided to use MySQL's Workbench, but that screen is so 'busy'. The local equipment was some VGA or not-much-better projector. Screen text was totally unreadable! My preference these days is to slave everyone's screen to mine, using VNC software. It's just like a slide/movie projector and as the airlines like to advertise: everyone has their own personal screen! (plus, can adjust resolution, control screen enlargement, etc, to suit personal preferences) However, a lot of training is moving away from "lectures" and certainly "class rooms". It is becoming an async world, and even if a group congregate into a single room, classes are organised so that each can work at his/her own pace. So, features to join all in "lock step" may not be so often required... (apologies if more than two-cents' worth) -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 3/08/19 5:50 PM, Chris Angelico wrote: On Sat, Aug 3, 2019 at 3:36 PM DL Neil wrote: On 3/08/19 4:02 PM, Terry Reedy wrote: Good. Master-satellite would be much easier. We added line numbers to IDLE's editor last week, so verbal feedback from satellite to master should be sufficient for many purposes. Elsewhere in this thread others, have been looking at NAT and broker arrangements. It has been v.interesting to read. If it is a corporation's project, then this is an option. The business of choosing ports and opening firewalls is a (?mere) matter of standardisation and coordination. (cough, cough, mumble, mumble) However, if we are talking about a public product, eg TeamViewer; then ease of operation comes to the fore. (much though I disagree with what amounts to an abuse of port-80 - specialists trying to 'manage' Internet traffic must really have things to say about such) The reason I mentioned "TeamViewer" (and A.N.Other mentioned BitTorrent) is that client-server is so much easier to implement - even if (using this example) the two (pair-programming) start as clients to some central server, but later comms are 'delegated'/re-directed to become peer-to-peer or go-direct. In the case of TV, which I use in (unpaid, much put-upon, family - you know this song!) 'technical support' mode, both the one seeking help and my own computer have to separately log-in to the TV system, the second asking to connect to the first... Elsewhere in the thread there is much discussion of this. Regardless of the "we are all adults here" philosophy, my feeling (stuck-in-the-mud though it might be) is that one person/system has to have 'control', and the other, the 'pair' (or the 'tutor') is invited to see/do 'whatever'. However, r/o would be a show-stopping limitation. When pair programming involves training (tutor and student, or senior and junior programmer), forcing the more experienced person to stay hands-off is a very good thing; it forces the less experienced person to actually keyboard every change, and thus is more likely to understand what's going on. But when it's two peers, you'll often want to switch out who's in control. Depending on the architecture, this might be a simple matter of flipping a switch and changing who's master and who's on a read-only clone. I can't see the r/o version in pair-programming - although 'elsewhere' people have mentioned programmer interviews, so maybe that's it. In pair-programming both have a contribution to make. The key, requiring both technical and social/inter-personal considerations (see discussion, elsewhere), is to understand one's current rôle, and to have a clear 'break' when 'swapping seats' - in radio, that is the reason for finishing with "over" (cue Leslie Nielsen sketch), and on a ship's bridge there is a clear announcement, eg "Fred has the conn", so that 'everyone' knows who's in-charge 'now'! To me, that is mostly an inter-personal communications issue. I don't really want 'some computer' deciding when and what I might do. Others might prefer the opposite. Also, there are scenarios when both (of the pair) might be contributing by 'coding' concurrently, eg one writing tests and the other code, or one writing one class and the other a second. (but you can debate if that is "pair-programming") Python's philosophy already covers this with: "we're all adults here"... (see also 'trust', below) 4. Require encryption of some sort if over the public internet. Just because people download code from strangers over http is not a reason to encourage carelessness. I am pretty ignorant on what this would mean. TLS? TLS doesn't really solve this problem. If you have a single central server, TLS just tells you that you're talking to that server, without proving anything about who's on the other end. Even if you directly connect the two nodes, TLS wouldn't prove who that is, unless you get a dedicated certificate. What it *can* prove is that your data stream hasn't been tampered with en route, but the problem of receiving code from strangers is still an issue. Ultimately, pair programming depends on a measure of trust - you have to be confident that the person you're pairing with isn't going to be maliciously messing with your system. As above, using a client-server relationship, thus TLS/SSH are relatively natural, and certainly common, components of the whole. OT: the world of certificates has been revolutionised by LetsEncrypt.org and their free services. I assume a level of trust. Why would you pair-program with someone untrustworthy? Either you're a team or not! That said, and thinking back to the different scenarios (above), I can see the r/o option being useful in such a case. For example, some of my stats clients like to run through the code. It's a form of checking/testing, so I don't mind - they read (the math of) code far better than they can write/structure it! However, I definitely don't
asyncio, transports, protocols, etc.
Hello, I didn't get a response to this before, possibly because of lack of concision. I'd like to ask whether (provided I'm understanding this): https://docs.python.org/3/library/asyncio-protocol.html#tcp-echo-server could be improved by adding: """ Create a TCP echo server using the loop.create_server() method, send back received data. This is done by defining the Protocol, which gets the transport from the server when it is created by asyncio. """ before it, because these concepts have only just been introduced, and also whether the echo server should really be closing the connection, given RFC 862 seems to suggest it should stay open. Original message below. Thank you, Hugh Hello, I'm trying to get my head around asyncio, and I think I'm mostly there now, (but expect to be proved wrong :-)!). It appears to be about the newest of the PEPs according to my searches, including PEP 0, so I don't expect a huge amount of supporting documentation out there yet. Looking at: https://docs.python.org/3/library/asyncio-protocol.html#tcp-echo-server I know the page introduces the relationships between protocols, transports and the servers/clients that use them. When I read this code it took me longer than I would wish :-) to realise that the example defining the Echo server was doing this through the protocol, (yes, it says it *right there* :-)!) and not a Server class, so for some time I was puzzled about where 'transport' was being defined. Given these concepts are new on this page, at least ostensibly, would it make sense to introduce this example with something like: """ Create a TCP echo server using the loop.create_server() method, send back received data. This is done by defining the Protocol, which gets the transport from the server when it is created by asyncio. """ just to refresh the connection between the things in the mind of the reader? Also, according to my reading of RFC 862, I don't think the Echo server should be closing the connection just after echoing: """ TCP Based Echo Service One echo service is defined as a connection based application on TCP. A server listens for TCP connections on TCP port 7. Once a connection is established any data received is sent back. This continues until the calling user terminates the connection. """ I could have missed something here though. (If it is this protocol that is under discussion here, then a link might be useful, as well?) Why does this matter? Because it was not clear to me whether the closing of the connection was something that had to happen, as part of the functionality of the echo service or of asyncio itself. If I'm implementing something that does something based on the cmd or cmd2 module, interpreting commands, then having some kind of dialogue with the server matters. Writing documentation so that everyone will understand it and NOT get the wrong end of the stick is difficult. I don't know if this would make things more confusing for others, or even if it might have helped me. At the moment, I think it might be in the right direction, though. Thank you, Hugh -- -- Dr. Hugh Sasse, BSc(Hons), PhD Computer Systems Electronic Engineer School of Engineering and Sustainable Development DE MONTFORT UNIVERSITY -- https://mail.python.org/mailman/listinfo/python-list
Re: Remote/Pair-Programming in-the-cloud
On 5/08/19 4:04 AM, Ian Kelly wrote: On Sat, Aug 3, 2019, 9:25 AM Bryon Tjanaka wrote: Depending on how often you need to run the code, you could use a google doc and copy the code over when you need to run. Of course, if you need linters and other tools to run frequently this would not work. I've conducted a number of remote interviews using Google Docs and while it's okay for that use case I wouldn't really recommend it for actual productivity. It's not designed to be an IDE nor does it satisfactorily replace one. Agreed. I'm not sure if it is a real advantage to see 'keystrokes' during such interviews, but you can certainly do that with the Cloud9 system (please see other post, a few hours back). Another product which is worth review is PythonAnywhere (.com) which also allows 'sharing'. -- Regards =dn -- https://mail.python.org/mailman/listinfo/python-list