"/a" is not "/a" ?

Emanuele D'Arrigo manu3d at gmail.com
Fri Mar 6 14:17:07 EST 2009


Hi everybody,

while testing a module today I stumbled on something that I can work
around but I don't quite understand.

>>> a = "a"
>>> b = "a"
>>> a == b
True
>>> a is b
True

>>> c = "/a"
>>> d = "/a"
>>> c == d
True               # all good so far
>>> c is d
False             # eeeeek!

Why c and d point to two different objects with an identical string
content rather than the same object?

Manu



More information about the Python-list mailing list