Module loading trickery
jeanmichel at sequans.com
Tue Oct 5 17:49:09 CEST 2010
Jonas Galvez wrote:
> Is there a way to "inject" something into a module right before it's
> For instance, a.py defines "foo". b.py print()s "foo".
> I want to load b.py into a.py, but I need to let b.py know about "foo"
> before it can execute.
> Is this any way to achieve this?
> -- Jonas
No that would mean that a imports b which imports a => circular imports.
Usually it's a cue for bad design.
People solve it by either merging the 2 modules into 1 or defining 'foo'
in a 3rd module.
You can do also something like :
foo = 'I am foo'
More information about the Python-list