global variables
David S.
davidschein at alumni.tufts.edu
Mon Mar 7 16:18:02 EST 2005
M.N.A.Smadi <smadim2 <at> grads.ece.mcmaster.ca> writes:
> I need to have a varaible that will contain a value that will be
> modified in one file, and when coming back to the same file it
> should retain the same value.
You must import the module in which the variable lives and qualify it
appropriately.
So, if you have the following files
trash1.py
var = 1
trash2.py
import trash1
trash1.var = 2
trash3.py
import trash1
print trash1.var
you can run the interpreter and:
>>>import trash2
>>>import trash3
2
More information about the Python-list
mailing list