python string comparison oddity
faheem at email.unc.edu
Wed Jun 18 21:26:57 CEST 2008
I was wondering if anyone can explain this. My understanding is that 'is'
checks if the object is the same. However, in that case, why this
inconsistency for short strings? I would expect a 'False' for all three
comparisons. This is reproducible across two different machines, so it is
not just a local quirk. I'm running Debian etch with Python 2.4.4 (the
In : a = '--'
In : a is '--'
In : a = '-'
In : a is '-'
In : a = 'foo'
In : a is 'foo'
More information about the Python-list