class version of func_globals?
Dave Angel
davea at ieee.org
Tue Dec 29 06:18:30 EST 2009
samwyse wrote:
> Is there any way to get the global namespace of the module in which a
> class was defined? Answers for both Python 2.x and 3.x will be
> cheerfully accepted.
>
>
I don't know if it's the same in general, but consider the following
sequence in 2.6:
import sys
class MyClass(object):
pass
print "class--", dir(MyClass)
print "module--", dir(MyClass.__module__)
mod = sys.modules[MyClass.__module__]
print mod
print "globals--", dir(mod)
DaveA
More information about the Python-list
mailing list