Re: variable declaration
From: Brian van den Broek (bvande_at_po-box.mcgill.ca)
Date: 02/08/05
- Next message: Mailer: "Python mail filter"
- Previous message: Duncan Booth: "Re: pass named parameters to python"
- Maybe in reply to: Michael Tobis: "Re: variable declaration"
- Next in thread: Thomas Bartkus: "Re: variable declaration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 08 Feb 2005 11:55:07 -0500 To: python-list@python.org
Brian van den Broek said unto the world upon 2005-02-07 20:36:
> Steve Holden said unto the world upon 2005-02-07 17:51:
<SNIP>
>> The reason global is a wart can clearly be seen in the following example:
>>
>> >>> x = 3
>> >>> def f(tf, v):
>> ... if tf:
>> ... global x
>> ... x = v
>> ...
>> >>> f(0, 5)
>> >>> x
>> 5
>> >>>
<SNIP>
> Hi,
>
> Steve's example makes my brain hurt. :-)
>
> I'd appreciate it if someone could tell me if I am understanding the
> example correctly. (My grasp of the terminology and issues at play is a
> bit shaky.)
<SNIP>
> Thanks for any confirmation of my understanding / rectification of same.
> Best,
>
> Brian vdB
Thanks to everyone whose contributed to this sub-thread! I've learned
a lot. :-)
And, for posterity, some one wrote me off-list to correct my claim
that in
if False:
# thousands of lines of code here
the thousands of lines "would never get executed". Simplifying their
example, they pointed out:
>>> False = 'evil trickery'
>>> if False:
... print 'Surprise!'
...
Surprise!
>>>
Which leads me naturally to the differences between 'if False:' and
'if ):' that Duncan Booth pointed to. (Where'd I put the Tylenol.)
Thanks again to all,
Brian vdB
- Next message: Mailer: "Python mail filter"
- Previous message: Duncan Booth: "Re: pass named parameters to python"
- Maybe in reply to: Michael Tobis: "Re: variable declaration"
- Next in thread: Thomas Bartkus: "Re: variable declaration"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|