<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
You're right.  By default assignments inside functions create local
variables within the function, even if there happens to be a variable by
the same name in the module scope.
<p>Specify 'global' to make your function assign to the module scope.
<p>Example:<tt></tt>
<p><tt>>>> AYS = "hey"</tt>
<br><tt>>>> def setEnviroment():</tt>
<br><tt><font color="#006600">...  global AYS</font></tt>
<br><tt>...  AYS = "NUMBER 9"</tt>
<br><tt>...</tt>
<br><tt>>>> def getEnviroment():</tt>
<br><tt>...    return AYS</tt>
<br><tt>...</tt>
<br><tt>>>> getEnviroment()</tt>
<br><tt>'hey'</tt>
<br><tt>>>> setEnviroment()</tt>
<br><tt>>>> getEnviroment()</tt>
<br><tt>'NUMBER 9'</tt><font color="#006600"></font>
<p>Pablo Prieto wrote:
<blockquote TYPE=CITE>Hi all of you there!
<p>#This is my question
<p>AYS = ""
<p>def setEnviroment():
<br>  AYS = "NUMBER 9"
<p>def getEnviroment():
<br>  return AYS
<p>#This is the end...
<p>The function getEnviroment always return "". I guess AYS is declared
<br>twice, One is module-scope and the other is local to setEnviroment,
so
<br>I've got two differents variables.
<p>How can I make the variable AYS global to setEnviroment, so I'd be able
<br>to return "NUMBER 9" in getEnviroment?. (Don't say return "NUMBER9".
<br>I'll get annoyed :))
<p>Well, Have a nice summer all of you (or Winter if you are in the other
<br>side of the floor).
<p>Pablo.</blockquote>
</html>