None assigment

Martin von Loewis loewis at informatik.hu-berlin.de
Fri Feb 9 19:02:24 CET 2001


Gregoire Welraeds <greg at perceval.be> writes:

> > There's nothing special about the name "None"; it's just a variable,
> > like any other. 
> <snip>
> > After doing "None = 2", you can "del None" to get the default value 
> > back.
> 
> If we follow that logic, I could use any non assigned variable to have the
> following working:

What is the logic here? None is a builtin name (i.e. living in the
__builtins__ dictionary/module), like str, id, and many others. If you
assign to None, then you get another binding in the global or local
namespace, which hides the builtin name. If you del None from the
global namespace, you see the builtin again.

Regards,
Martin



More information about the Python-list mailing list