Newbie: How to create a global or static variable?
Adrian Eyre
a.eyre at optichrome.com
Mon Jan 31 11:11:12 EST 2000
More information about the Python-list mailing list
Mon Jan 31 11:11:12 EST 2000
- Previous message (by thread): Newbie: How to create a global or static variable?
- Next message (by thread): Riskless deletion of nested structures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 1 - How do I create a global variable in a script that is in scope for
> all the functions defined in the script?
myGlobal = "spam"
def changeMyGlobal(what):
global myGlobal
myGlobal = what
print myGlobal
changeMyGlobal("eggs, bacon and spam")
print myGlobal
> 2 - Can I create a static variable with an initial assignment in a
> function?
No. You'll have to use either class attributes, or globals (or some
other Python hackery.)
--------------------------------------------
Adrian Eyre <a.eyre at optichrome.com>
http://www.optichrome.com
- Previous message (by thread): Newbie: How to create a global or static variable?
- Next message (by thread): Riskless deletion of nested structures
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list