getattr() in default namespace.

Robert Brewer fumanchu at amor.org
Thu Apr 8 11:34:03 EDT 2004


SimonVC wrote:
> How do you use getattr() to get a refernce to a function defined in
> the default namespace..

If you must use getattr, and you're doing this in a module, try:

import sys

def b():
    pass

print getattr(sys.modules[__name__], 'b')



FuManChu




More information about the Python-list mailing list