None assigment

Aahz Maruch aahz at panix.com
Thu Feb 8 12:58:42 EST 2001


In article <mailman.981652444.20002.python-list at python.org>,
Gregoire Welraeds  <greg at perceval.be> wrote:
>
>Always according to this logic, I have tried to run the following:
>
>>>> a= [1,'',3]
>>>> b= 0 # b could be anything
>>>> del b
>>>> filter(b,a)
>
>but this won't work either as stated in the documentation. Referencing a
>"deleted" variable is an error at least until another value is assigned to
>it (see del statement section in the tutorial).
>
>It seems that (the so called variable) None is neither a variable like any
>other, nor is it a label as stated by Simon Brunning in another post.

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()

None has a bit of magic associated with it, but not much.
-- 
                      --- 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