Oddity in 2.4 with eval('None')

Leif K-Brooks eurleif at ecritters.biz
Mon Dec 20 15:10:17 EST 2004


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.
 >>> print None
None
 >>> print eval('None')
None
 >>> globals()['None'] = "spam"
 >>> print None
None
 >>> print eval('None')
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')"?



More information about the Python-list mailing list