[Jeremy Hylton] > As Tim will explain in a post that hasn't made it to DejaNews yet, > earlier versions of Python did not define Neither does 2.1: changing the implementation didn't change the Ref Man, and the Ref Man still declines to define the semantics or promise that the behavior today will persist tomorrow. > the behavior of assignment Or any other reference. > before a global statement. > ... > It's unclear what we should happen in this case. It could be an error, > since it's dodgy and the behavior will change with 2.1. "Undefined behavior" is unPythonic and should be wiped out whenever possible. That these things were dodgy was known from the start, but when the language was just getting off the ground there were far more important things to do than generate errors for every conceivable abuse of the language. Now that the language is still getting off the ground <wink>, that's still true. But changes in the meantime have made it much easier to identify some of these cases; like: > The recent round of compiler changes uses separate passes to determine a > name's scope and to generate code for loads and stores. The behavior of "global x" after a reference to x has never been defined, but it's never been reasonably easy to identify and complain about it. Now that name classification is done by design instead of by an afterthought "optimization pass", it should be much easier to gripe. +1 on making this an error now. And if 2.1 is relaxed to again allow "import *" at function scope in some cases, either that should at least raise a warning, or the Ref Man should be changed to say that's a defined use of the language. ambiguity-sucks-ly y'rs - tim
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4