Newbie question.

entropia entropiamax at jazzfree.com
Tue Jun 6 09:25:14 EDT 2000


Pablo Prieto escribió:

> Hi all of you there!
>
> #This is my question
>
> AYS = ""
>
> def setEnviroment():
>   AYS = "NUMBER 9"
>
> def getEnviroment():
>   return AYS
>
> #This is the end...
>
> The function getEnviroment always return "". I guess AYS is declared
> twice, One is module-scope and the other is local to setEnviroment, so
> I've got two differents variables.
>
> 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 :))
>
> Well, Have a nice summer all of you (or Winter if you are in the other
> side of the floor).
>
> Pablo.
>
> --
> http://www.python.org/mailman/listinfo/python-list

That's easy:
    AYS=""
def set():
    global AYS
    AYS="NUMBER 9"

def get():
    return AYS






More information about the Python-list mailing list