'is' versus '=='
Michael Hudson
mwh at python.net
Mon May 7 13:24:03 EDT 2001
More information about the Python-list mailing list
Mon May 7 13:24:03 EDT 2001
- Previous message (by thread): Non-caching import?
- Next message (by thread): 'is' versus '=='
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Aaron Ginn <aaron.ginn at motorola.com> writes: > Maybe I have an incorrect understanding of the 'is' operator, but I > was under the impression that 'is' and '==' operated the same way. Nope. >From http://www.python.org/doc/current/ref/comparisons.html: The operators is and is not test for object identity: x is y is true if and only if x and y are the same object. x is not y yields the inverse truth value. The moral? Don't use "is" on strings. The results are predictable, but unlikely to be what you want. Cheers, M. -- You can lead an idiot to knowledge but you cannot make him think. You can, however, rectally insert the information, printed on stone tablets, using a sharpened poker. -- Nicolai -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html
- Previous message (by thread): Non-caching import?
- Next message (by thread): 'is' versus '=='
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list