I've a name of a class stored in var, which I need to create an object from.
However I do not know in which module it is defined (if I did, I would just call getattr(module,var), but I do know it's imported.
Should I go over every module and test if the class is defined there ? How do I do it in python ?
What if I have the module + class in the same var, how can I create an object from it ? (ie var = 'module.class')
Cheers,
Ze
Classes are not added to a global registry in Python by default. You'll need to iterate over all imported modules and look for it.
Python equivalent for Ruby's ObjectSpace?