using 'global' across source files.
Bram Stolk
bram at sara.nl
Tue Jan 2 09:15:24 EST 2001
Remco,
Many thanks for your reply.
However, your suggested changes do not fix the problem.
I have now:
# funcs.py
def change_val() :
global val
val = val * 2
# prog.py
val = 100
import funcs
funcs.change_val()
print val
However, this gives me:
bram at gazoo> python -i prog.py
Traceback (most recent call last):
File "prog.py", line 7, in ?
funcs.change_val()
File "funcs.py", line 5, in change_val
val = val * 2
NameError: There is no variable named 'val'
--
------------------------------------------------------------------------------
Bram Stolk, VR Specialist.
SARA Academic Computing Services Amsterdam, PO Box 94613, 1090 GP AMSTERDAM
email: bram at sara.nl Phone +31-20-5923059 Fax +31-20-6683167
"I heard if you play the NT-4.0-CD backwards, you get a satanic message."
"Thats nothing, if you play it forward, it installs NT-4.0"
------------------------------------------------------------------------------
More information about the Python-list
mailing list