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
<[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+
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
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
[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
>
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
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
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
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: