Showing posts with label equality. Show all posts
Showing posts with label equality. Show all posts

Monday, April 27, 2009

Bizarre Python behavior

A redditor pointed this out, but I'm having difficulty locating the link now:

Identity can be quite surprising in Python:

>>> x = 'a'
>>> y = 'a'
>>> x is y
True
>>> x = ' a'
>>> y = ' a'
>>> x is y
False