[Pythonmac-SIG] string ids
Feat
jf at ai.univ-paris8.fr
Mon Dec 29 17:04:46 CET 2008
The only way to ensure it will *always* work is when sharing values:
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
>>> c1 = 'red' ; c2 = 'green' ; colors = (c1, c2)
>>> [x is c2 for x in colors]
[False, True]
Any new list will break the identity:
>>> [x is c2 for x in 'red green'.split()]
[False, False]
>>> [x is 'green' for x in 'red green'.split()]
[False, False]
I'm baffled...
More information about the Pythonmac-SIG
mailing list