Marko Rauhamaa <ma...@pacujo.net> writes: > Ben Finney <ben+pyt...@benfinney.id.au>: > > > Use ‘==’, since that's all that matters for getting a value that will > > work fine. > > You are telling me to use '==' if I choose string objects and 'is' if I > choose some other objects.
No. I'm telling you that ‘is’ is *wrong* for comparing strings, because it is unreliable. > I prefer a solution that works regardless of what objects I choose for > identifiers. Some languages have a “symbol” type, whose values can be directly compared. Python doesn't have such a type. If you want to use strings as a substitute, go ahead: they work fine. But compare strings by *equality*, not identity, because it's their *values* which will be the identifiers. Their object identity will not be reliably comparable. That's what everyone has been telling you all along, for reasons already explained. > There really is no taboo against string object identity if you know what > you are doing. You, as has been amply demonstrated, do not, despite your dogmatic assertions. -- \ “Under democracy one party always devotes its chief energies to | `\ trying to prove that the other party is unfit to rule — and | _o__) both commonly succeed, and are right.” —Henry L. Mencken | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list