Hi<br>this  variable is local to function<br>
do this<br>
def setExitCode():<br>
   global _exitcode<br>
   _exitcode = 1<br><div><span class="gmail_quote">On 7 May 2007 00:00:38 -0700, <b class="gmail_sendername"><a href="mailto:lokesh.jagasia@gmail.com">lokesh.jagasia@gmail.com</a></b> <<a href="mailto:lokesh.jagasia@gmail.com">
lokesh.jagasia@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi. Sorry to sound like a noob but that's what I am when it comes to
<br>Python. I just wrote the below module and it behaves funny.<br><br>My python module:<br><br>_exitcode = 0<br><br>def setExitCode():<br>    _exitcode = 1</blockquote><div><br>
this  variable is local to function <br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">if __name__ == '__main__':<br>    print _exitcode<br>    setExitCode()<br>
    print _exitcode<br><br>Actual O/P:<br>0<br>0<br><br>I expected to see an output of 0 followed by 1. But it turns out that<br>the _exitcode variable is not changed at all. It seems that<br>setExitCode() might be editing a local copy of the _exitcode variable.
<br>But then, how do I tell it to change the value of the module variable<br>and not its local variable.<br><br>I've been through the modules section of Python docs and a few ebooks<br>as well, all suggest that it shouldn't be working this way.
<br><br>Please help out ppl.<br><br>Thanks<br><br>--<br><a href="http://mail.python.org/mailman/listinfo/python-list">http://mail.python.org/mailman/listinfo/python-list</a><br></blockquote></div><br><br clear="all"><br>-- 
<br>Regards--<br>Rishi Pathak<br>National PARAM Supercomputing Facility<br>Center for Development of Advanced Computing(C-DAC)<br>Pune University Campus,Ganesh Khind Road<br>Pune-Maharastra