On Wed, Dec 07, 2011 at 03:49:10PM +0000, Michael Meeks <michael.meeks@suse.com> wrote:
mod = __import__ ( "actual python-module-name" ) implHelper = mod.__dict__.get( "g_ImplementationHelper" , None ) is supposed to work, or indeed any half-way decent documentation on what the object is that __import__ returns and by what I don't mean floral vagueness but a concrete set of methods/properties and their types that would let us find an internal variable definition ;-)
---- mod = __import__("foo") ---- is the same as ---- import foo as mod ---- and in case foo and mod is the same, then it's the same as ---- import foo ---- So that form is just longer form in case the module to import is not known at build-time, or in case for some weird reason the original module name is not acceptable. Second line: ---- implHelper = mod.__dict__.get( "g_ImplementationHelper" , None ) ---- It "casts" the module to a dictionary (hasmap), then looks up the "g_ImplementationHelper" key there: if it's not found, it falls back to None. In short, it checks if there is a funcion named "g_ImplementationHelper" in "actual python-module-name". (No, I'm not sure what else that dictionary contains, you can probably fool that simple check by providing a *class* named g_ImplementationHelper in the module, etc.)
Attachment:
pgpqHwpN2nN00.pgp
Description: PGP signature