None assigment

Aahz Maruch aahz at panix.com
Fri Feb 9 05:49:44 CET 2001


In article <_BHg6.195181$ge4.67634054 at news2.rdc2.tx.home.com>,
Rainer Deyke <root at rainerdeyke.com> wrote:
>"Aahz Maruch" <aahz at panix.com> wrote in message
>news:95umoi$is5$1 at panix2.panix.com...
>>
>> What you're missing is the issue of Python scopes.  Try this:
>>
>> b=2
>> def foo():
>>     b=4
>>     print b
>>     del b
>>     global b
>>     print b
>> foo()
>
>And what *you*'re missing is that whether a variable is local or global is
>determined at compile time (in the absensce of 'exec' or 'from ... import
>*').  The above does not work.  

It doesn't, eh?  Did you try running it?  (After a few blunders of my
own, I rarely post code to c.l.py without testing it -- just to make
sure.)  Note that this is not the same as the issue with None, but it's
still a scoping issue.
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Actually, I've found that Usenet has helped a lot with my terror of
social stupidity.  Seeing people I really like and respect behave like
idiots in public has been very beneficial."  --Rachael Lininger



More information about the Python-list mailing list