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
Excellent! Exactly what I wanted, but wasn't clever enough to figure
out for myself. Thank you very much.
But dir(mod) gives you only names, not objects (though, of course, you
can get them "manually" with getattr(mod, name)). To get from a class
the same you get from function using func_globals (i.e. dictionary with
names as keys and objects as values), use:
mod = sys.modules[MyClass.__module__] # (as above)
vars(mod) # or mod.__dict__, though vars(mod) seems to me more elegant
Cheers,
*j
--
Jan Kaliszewski (zuo) <z...@chopin.edu.pl>