[Tutor] scoping oddity
Michael.Coll-Barth@VerizonWireless.com
Michael.Coll-Barth at VerizonWireless.com
Sat May 7 18:56:55 CEST 2005
Tanja, Bob, Brian,
Many thanks for your help.
And perhaps the way in which I posed the question was misleading. In a
process I am writing, I was actually trying not to use global variables, as
I agree with Brian. However, I inadvertantly used a variable within a 'def'
block that I had used outside of that 'def' block and got 'bitten'. It was
in tracking my bug down that I became a tad confused.
Actually, now that I know the answer, it all seems so obvious. At least
until I get bitten by it again! D'OH!
Michael
-----Original Message-----
Behalf Of Brian van den Broek
>>
>> > def testb(astr):
>> > x = x - 1
>> > print astr, x
>>
global will indeed fix that, yes. But, I've been lead to believe that one's
first thought when tempted to write a global statement should be to reflect
on whether that temptation isn't the symptom of a sub-optimal design.
___________________________________________________________________
The information contained in this message and any attachment may be
proprietary, confidential, and privileged or subject to the work
product doctrine and thus protected from disclosure. If the reader
of this message is not the intended recipient, or an employee or
agent responsible for delivering this message to the intended
recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify me
immediately by replying to this message and deleting it and all
copies and backups thereof. Thank you.
More information about the Tutor
mailing list