'is' versus '=='
Michael Hudson
mwh at python.net
Mon May 7 13:24:03 EDT 2001
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
More information about the Python-list
mailing list