How to pass a reference to the current module
Paul Rubin
http
Fri Aug 3 21:45:21 EDT 2007
Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> namespace = module.__dict__
> return namespace[name]
Am I missing something? It's likely that I just don't understand
the problem, but I don't understand these dictionary extractions
for what I thought would be an attribute lookup:
Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
>>> import math
>>> parrot = getattr(math, 'sqrt')
>>> print parrot(3)
1.73205080757
>>>
That just seems like a cleaner way to access stuff in a module,
using the published interface instead of an implementation detail.
More information about the Python-list
mailing list