None assigment
Steve Holden
sholden at holdenweb.com
Thu Feb 8 13:50:00 EST 2001
More information about the Python-list mailing list
Thu Feb 8 13:50:00 EST 2001
- Previous message (by thread): None assigment
- Next message (by thread): None assigment
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Simon Brunning" <SBrunning at trisystems.co.uk> wrote in message news:mailman.981653763.25307.python-list at python.org... > > From: Gregoire Welraeds [SMTP:greg at perceval.be] > > > After doing "None = 2", you can "del None" to get the default value > > > back. > > Hmm. This is true - I didn't know that. > > > If we follow that logic, I could use any non assigned variable to have the > > following working: > > > > >>> a= [1,'',3] > > >>> filter(b,a) > > > > but this won't work as the interpreter complains that there is no variable > > named b. > > You can't do this with *ordinary* labels - by del'ing them, you are > un-assigning them. But the 'None' label is *extraordinary*, obviously. > Oh, no it isn't. It's just defined in the __builtins__ namespace. You can't delete this built in version, but you can, with enough effort, redefine it: >>> None = 22 >>> print None 22 >>> del None >>> print None None >>> __builtins__.None = 42 >>> print None 42 >>> del None Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: There is no variable named 'None' >>> > > 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. > > It *is* a label - try this: > > >>>print None > None > >>> None = 'spam' > >>> print None > spam > > So, clearly, None is a label. > Yes, but here you've added another definition of None in the module namespace, not redefined the one you had in __builtins__ to start with. > Now that I look at this problem, I'm totally confused about None. > Any > > explanaition is welcome. Anyway, I don't understand that one can override > > None. Could you give me at least one single good reason to do that. > > I can give you a good reason *not* to - it will confuse the hell out of > people. ;-) > > I'm sure one of the Python gurus will give you a bit more background, but I > think that the short answer is this - leave 'None' alone to get on with its > job, and you won't have any problems. > On this we can, I hope, all agree. regards Steve
- Previous message (by thread): None assigment
- Next message (by thread): None assigment
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list