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

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -