In Python 2.4, although None can't be directly assigned to,
globals()['None'] can still be; however, that won't change the value of
the expression "None" in ordinary statements. Except with the eval
function, it seems:
Python 2.4 (#2, Dec 3 2004, 17:59:05)
[GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> print None[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> print eval('None')[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> globals()['None'] = "spam"
>>> print None[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> print eval('None')[/color][/color][/color]
spam
I don't really mind this weird behavior; I'm just curious about it. Does
anyone know what might be going on in Python's internals to cause the
difference between "print None" and "print eval('None')"?
globals()['None'] can still be; however, that won't change the value of
the expression "None" in ordinary statements. Except with the eval
function, it seems:
Python 2.4 (#2, Dec 3 2004, 17:59:05)
[GCC 3.3.5 (Debian 1:3.3.5-2)] on linux2
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> print None[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> print eval('None')[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> globals()['None'] = "spam"
>>> print None[/color][/color][/color]
None[color=blue][color=green][color=darkred]
>>> print eval('None')[/color][/color][/color]
spam
I don't really mind this weird behavior; I'm just curious about it. Does
anyone know what might be going on in Python's internals to cause the
difference between "print None" and "print eval('None')"?
Comment