Python __import__ parameter confusion
- by CMC
I'm trying to import a module, while passing some global variables, but it does not seem to work:
File test_1:
test_2 = __import__("test_2", {"testvar": 1})
File test_2:
print testvar
This seems like it should work, and print a 1, but I get the following error when I run test_1:
Traceback (most recent call last):
File ".../test_1.py", line 1, in <module>
print testvar
NameError: name 'testvar' is not defined
What am I doing wrong?