What is the cleanest way to for a module to access objects from the script that imports it?

noamsml at gmail.com noamsml at gmail.com
Fri Oct 27 18:48:18 EDT 2006


Wouldn't importing and re-importing the same modules cause considerable
resource bulk? Or does python cache that stuff?

On Oct 27, 6:28 pm, Gabriel Genellina <gagsl... at yahoo.com.ar> wrote:
> At Friday 27/10/2006 18:53, noam... at gmail.com wrote:
>
> >I am new to python and am currently writing my first application. One
> >of the problems I quickly ran into, however, is that python's imports
> >are very different from php/C++ includes in the sense that they
> >completely wrap the imported script in a module object. One of the
> >problems with this was that a plugin system that I am making requires
> >use of objects, classes and the such from the original script. Thus, on
> >one hand, I am hesitant to use execfile(), since I *do* want to wrap
> >the plugin up, but on the other hand, I want the plugin to be able to
> >use functions from the original script. Any ideas?Put the bulk of your "original script" into modules so they are
> easily importable from inside the plugins.
> In your application, you can scan the available plugins (using
> os.listdir by example) and import them.
> (Of course this is risky so you must trust the plugin developers...)
>
> --
> Gabriel Genellina
> Softlab SRL
>
> __________________________________________________
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> ¡Abrí tu cuenta ya! -http://correo.yahoo.com.ar




More information about the Python-list mailing list