Newbie question.
Randall Hopper
aa8vb at yahoo.com
Tue Jun 6 06:35:46 EDT 2000
Pablo Prieto:
|Hi all of you there!
Hi!
Try this:
|How can I make the variable AYS global to setEnviroment, so I'd be able
|to return "NUMBER 9" in getEnviroment?. (Don't say return "NUMBER9".
|I'll get annoyed :))
...
|AYS = ""
|
|def setEnviroment():
global AYS # <-----------------------------
| AYS = "NUMBER 9"
|
|def getEnviroment():
| return AYS
Now, I'm not saying that's the best way to provide this interface.
But it fixes your example. Another idea:
class Environment:
def Set( val ):
self.ays = val
def Get():
return self.ays
Now:
env = Environment()
env.Set( "NUMBER 9" )
print env.Get()
--
Randall Hopper
aa8vb at yahoo.com
More information about the Python-list
mailing list