advanced module/import/namespace idioms

chuck cmedcoff at gmail.com
Sat Dec 31 08:39:27 EST 2005


Every once in awhile I run across a python module that might have
statements like:

for c in sys.modules[module].__dict__.values():

or

import __builtin__
__builtin__.__dict__['_'] = lambda x: x

Snurf also does some strange import trickory (see
http://bdash.net.nz/svn/snurf/trunk/snurf/dataStore/).

While I'm sure none of this stuff is rocket science, but rather just
"namespace manipulation" there is very little explanation in the python
world that explains these techniques.  I've googled around to try to
find articles/papers that explain such techniques but cannot find any.
Can anyone point out any refereces that discuss such
module/import/namespace idioms.




More information about the Python-list mailing list