Jim Jewett <jimjjewett at gmail.com> wrote: > > (In http://mail.python.org/pipermail/python-dev/2005-October/057251.html) > Eyal Lotem wrote: > > > Name: Attribute access for all namespaces ... > > > global x ; x = 1 > > Replaced by: > > module.x = 1 > > Attribute access as an option would be nice, but might be slower. > > Also note that one common use for a __dict__ is that you don't > know what keys are available; meeting this use case with > attribute access would require some extra machinery, such as > an iterator over attributes. This particular use case is easily handled. Put the following once at the top of the module... module = __import__(__name__) Then one can access (though perhaps not quickly) the module-level variables for that module. To access attributes, it is a quick scan through module.__dict__, dir(), or vars(). Want to make that automatic? Write an import hook that puts a reference to the module in the module itself on load/reload. - Josiah
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