None assigment
Neil Schemenauer
nas at arctrix.com
Thu Feb 8 13:55:40 EST 2001
On Thu, Feb 08, 2001 at 01:15:23PM -0500, D-Man wrote:
> Interesting. So normally "None" is a special keyword (that is a
> reference to an object) , but that doesn't prevent one from creating
> a local variable named "None" that shadows the keyword.
Sounds like something another P language would do. Things are
simpler. None is a builtin. It exists in the __builtin__
module. The buildin module is searched for names after the
global namespace is searched.
>>> print None # find the binding for None, it is in __builtin__
None
>>> None = "spam" # make a global binding for None
>>> print None
spam
>>> import __builtin__
>>> print __builtin__.None # __builtin__ binding is still there
None
>>> del None # remove global binding
>>> print None
None
>>> __builtin__.None = "spam" # change __builtin__ binding (evil)
>>> print None
spam
Cheers,
Neil
More information about the Python-list
mailing list