Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.