getattr() in default namespace.
SimonVC
python at simon.vc
Thu Apr 8 06:47:46 EDT 2004
Hi group, long time reader first time poster (ive always wanted to say
that).
How do you use getattr() to get a refernce to a function defined in
the default namespace..
eg:
>>> dir()
['__doc__', '__name__', 'b1', 'b2', 'b3', 'rd']
>>> b1
<function b1 at 1876939>
>>> getattr(self, "b1")
Traceback (innermost last):
File "<console>", line 1, in ?
NameError: self
>>> getattr("b1")
Traceback (innermost last):
File "<console>", line 1, in ?
TypeError: getattr(): expected 2-3 args; got 1
More information about the Python-list
mailing list