How do I call anonymous classes from imported modules?
JoeSox
joesox at gmail.com
Sun Aug 19 23:00:07 EDT 2007
I am importing 3rd party modules via a plugin script. I wish to
iterate thru the modules and call a common method like .do_foobar() or
something with all the imports.
But I can't figure out how to do something like below without knowing
the class name before hand. Is there a builtin that helps call
classes anonymously?
(Calling example.do_foobar() works because I manually enter the classes' name)
>>> a=MyApp()
>>> sensorsList = []
>>> for snames in a.pluginsDict["sensorsplugins"]:
sensorsList.append(__import__(snames))
>>> sensorsList[0].example.do_foobar()
but I need something like
>>> sensorsList[0][0].do_foobar()
because I will not know the plugin class names.
--
Later, Joe
More information about the Python-list
mailing list