Re: N00b question on Py modules

2007-05-09 Thread Ant
On May 9, 2:47 pm, Sion Arrowsmith <[EMAIL PROTECTED]> wrote: ... > How so? Python style gurus discourage use of global variables. So > does all the C++ (and to a lesser extent C) advice I've ever > encountered. And Java outright forbids the concept. Class variables (public static), are the equiva

Re: N00b question on Py modules

2007-05-09 Thread Sion Arrowsmith
<[EMAIL PROTECTED]> wrote: >Thanks a lot for the responses ppl. Python's treatment of global >variables was an eye-opener. I have coded in Java & C/C++ in the past >and there the behaviour is diametrically opposite. How so? Python style gurus discourage use of global variables. So does all the C+

Re: N00b question on Py modules

2007-05-07 Thread lokesh . jagasia
Thanks a lot for the responses ppl. Python's treatment of global variables was an eye-opener. I have coded in Java & C/C++ in the past and there the behaviour is diametrically opposite. Cheers -- http://mail.python.org/mailman/listinfo/python-list

Re: N00b question on Py modules

2007-05-07 Thread Steven D'Aprano
On Mon, 07 May 2007 00:00:38 -0700, lokesh.jagasia wrote: > I expected to see an output of 0 followed by 1. But it turns out that > the _exitcode variable is not changed at all. It seems that > setExitCode() might be editing a local copy of the _exitcode variable. Yes, that's exactly what is happ

Re: N00b question on Py modules

2007-05-07 Thread Gary Herron
[EMAIL PROTECTED] wrote: > Hi. Sorry to sound like a noob but that's what I am when it comes to > Python. I just wrote the below module and it behaves funny. > > My python module: > > _exitcode = 0 > > def setExitCode(): > _exitcode = 1 > > if __name__ == '__main__': > print _exitcode >

Re: N00b question on Py modules

2007-05-07 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, lokesh.jagasia wrote: > My python module: > > _exitcode = 0 > > def setExitCode(): > _exitcode = 1 > > if __name__ == '__main__': > print _exitcode > setExitCode() > print _exitcode > > Actual O/P: > 0 > 0 > > I expected to see an output of 0 followed b

Re: N00b question on Py modules

2007-05-07 Thread rishi pathak
Hi this variable is local to function do this def setExitCode(): global _exitcode _exitcode = 1 On 7 May 2007 00:00:38 -0700, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote: Hi. Sorry to sound like a noob but that's what I am when it comes to Python. I just wrote the below module and it behav

Re: N00b question on Py modules

2007-05-07 Thread Christoph Haas
On Mon, May 07, 2007 at 12:00:38AM -0700, [EMAIL PROTECTED] wrote: > Hi. Sorry to sound like a noob but that's what I am when it comes to > Python. I just wrote the below module and it behaves funny. > > My python module: > > _exitcode = 0 > > def setExitCode(): > _exitcode = 1 > > if __nam

N00b question on Py modules

2007-05-07 Thread lokesh . jagasia
Hi. Sorry to sound like a noob but that's what I am when it comes to Python. I just wrote the below module and it behaves funny. My python module: _exitcode = 0 def setExitCode(): _exitcode = 1 if __name__ == '__main__': print _exitcode setExitCode() print _exitcode Actual O/P: