Jonas Galvez wrote:
Is there a way to "inject" something into a module right before it's
loaded?
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 :
a.py:
import b
foo = 'I am foo'
b.printThat(foo)
b.py:
def printThat(something):
print something
JM
--
http://mail.python.org/mailman/listinfo/python-list