python - How to access class module from object instance? -


i want access module-level variables of module defines class instance derived from. have instance work from. tried self.__class__.__module__[<some var>] unlike __class__ attribute returns class object, __module__ returns string name, not module object itself. how can module object in situation?

the __module__ attribute can used key in sys.modules dictionary:

import sys class_module = sys.modules[instance.__class__.__module__] 

Comments

Popular posts from this blog

python - Alternative to referencing variable before assignment -

vb.net - How to ignore if a cell is empty nothing -

Sort a complex associative array in PHP -