In python, what is contained in the info property of a module object? -


i'm looking creating plugin structure program , making core library treated plugins. in research came across code dynamically importing modules.

def __initialize_def(self, module):     """attempt load definition"""      # import works same py files , package modules strip!     if module.endswith(".py"):         name = module [:-3]     else:         name = module      # actual import     __import__(name)     definition = sys.modules[name]      # add definition if class available     if hasattr(definition, definition.info["class"]):         self.definitions[definition.info["name"]] = definition         logging.info("loaded %s" % name) 

i have tried understand code doing , i've succeeded point. however, can't understand latter part of code, these 2 lines:

if hasattr(definition, definition.info["class"]):     self.definitions[definition.info["name"]] = definition 

i can't figure out definition.info["<key>"] referring to.

what .info[] dictionary , hold? common python objects or module objects? useful for?

py> import sys,os py> sys.modules["os"].info["class"] traceback (most recent call last):   file "<stdin>", line 1, in <module> attributeerror: 'module' object has no attribute 'info' 

so info attribute must specific modules can used plugins in program.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -