R
RN
I have a 2 Python scripts that contain the following lines:
test.py
-------
from testmod import *
a1 = 10
modfunc()
testmod.py
-----------
def modfunc():
print a1
When I run test.py, it returns the following error:
File "testmod.py", line 2, in modfunc
print a1
NameError: global name 'a1' is not defined
My intent is to make a1 a global variable - so that I can access its value
in all functions of imported modules. What should I do?
Thanks in advance,
Rohit
test.py
-------
from testmod import *
a1 = 10
modfunc()
testmod.py
-----------
def modfunc():
print a1
When I run test.py, it returns the following error:
File "testmod.py", line 2, in modfunc
print a1
NameError: global name 'a1' is not defined
My intent is to make a1 a global variable - so that I can access its value
in all functions of imported modules. What should I do?
Thanks in advance,
Rohit