[Pythonmac-SIG] string ids

Feat jf at ai.univ-paris8.fr
Mon Dec 29 16:52:35 CET 2008


Maybe at first sight, but look:

Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
>>> C = 'red', 'green'
>>> [light is 'green' for light in C]
[False, False]

NB: I have to quit Python each time and reload to make sure the workspace hasn't been polluted by some other definition.

The problem is I teach the Python language, and this is no easy to explain behavior, unless it has something to do with interning strings for performance reasons in a for context, but even so, this isn't obvious for beginners.


More information about the Pythonmac-SIG mailing list