passing globals to imported module

James Tauber jtauber at jtauber.com
Mon Aug 16 15:45:17 EDT 2004


On Mon, 16 Aug 2004 21:24:16 +0200, "Mathias Waack" <M.Waack at gmx.de>
said:
> If you need the global _after_ the import you can just add in foo.py: 
> 
>   bar.my_global = my_global
> 
> Another solution would be to use a better design;)

Well, changing the design was my first thought too :-)

I just wondered whether there was a way to set the globals for the
import module *before* top level code in the improted module is
executed. I'm unclear what the second arg to __import__ actually
affects.

James
-- 
  James Tauber               http://jtauber.com/
  journeyman of some    http://jtauber.com/blog/




More information about the Python-list mailing list