
Hello, On Sat, 13 Feb 2021 23:10:59 +0900 "Stephen J. Turnbull" <turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
Chris Angelico writes:
Can you explain what would be improved by having a formalized standard?
The Language Reference together with the Library Reference *already* constitute a formalized standard. They are at least as precise as most W3C or IETF standards.
You must be kidding, right? Library Reference is full of underspecification and gaps. Here's a recent example which I bothered to report and which was even fixed: https://bugs.python.org/issue42559. Such reports can be easily closed either, so most people don't even try to report them after initial experience. Language Reference is also not exactly clearly and well structured, and leaves doubts about its completeness. For example, there's a common complaint (in narrow circles?) that Python's scoping rules are unclear and confusing. And indeed, https://docs.python.org/3/reference/executionmodel.html#naming-and-binding could be improved. I recently made a pass over it to clarify some things, once sweet day I'll post that as a patch, and let's see what happens (my bet is that it will be closed as many other patches). As an example from there:
If a name is bound in a block, it is a local variable of that block, unless declared as nonlocal or global. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable.
Based on the above, are global/nonlocal vars free in the code block they are declared in? It's hard to tell, because there's a soup of terminology - "bound", "defined"; just "block", "code block", etc. And description there and information available via the https://docs.python.org/3/library/symtable.html module sometimes don't agree (there are bugreports on that too). [] -- Best regards, Paul mailto:pmiscml@gmail.com