On Sunday 26 October 2003 01:25, Aahz wrote: > On Sat, Oct 25, 2003, Alex Martelli wrote: > > Or, we can make the _compiler_ aware of what is going on (and get just > > the same semantics as global) by accepting either a non-statement > > keyword (scope, as I suggested elsewhere) or a magicname for import, > > e.g. import __me__ as Barry suggested. Then __me__.x=23 can have just > > the same semantics as today "x=23" has if there is some "global x" > > somewhere around, and indeed it could be compiled into the same > > bytecode if __me__ was sufficiently special to the compiler. > > We've already got ``import __main__``; what does __me__ gain? import __main__ works only if the current module is being imported with the name __main__. Most modules will be using a different name most of the time (i.e. except when they're being used as main scripts, e.g. to run tests on them). Similarly, even if I know a module is named foo.py and am willing to hardcode that into the module's source, import foo as __me__ doesn't always work (submodules of packages, modules being run as main scripts for testing). Furthermore, the compiler cannot do anything special on most imports. __me__ would be designed as special (just like __future__ is) and allow the compiler to recognize the situation and do all it wants or needs, thus obviating the need for "declarative statements". Alex
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