On Sun, Mar 2, 2014 at 4:23 AM, Marko Rauhamaa <ma...@pacujo.net> wrote: > Ben Finney <ben+pyt...@benfinney.id.au>: > >> No. I'm telling you that ‘is’ is *wrong* for comparing strings, >> because it is unreliable. > > No, it isn't as long as the string object references have a common > assignment "pedigree." Assignment (including parameter passing) is > guaranteed to preserve identity of any object.
Of course it is, but your identity tests also depend on there NOT being a common object when there is NOT an "assignment pedigree". The positive is guaranteed; the negative is not. And if you don't care about a false positive - that is, that some other string with the same value matches - then what you actually want is equality, not identity, comparison. ChrisA -- https://mail.python.org/mailman/listinfo/python-list