Comparisons and singletons

Steven Watanabe Steven.Watanabe at autodesk.com
Fri Mar 24 15:40:15 EST 2006


PEP 8 says, "Comparisons to singletons like None should always be done
with 'is' or 'is not', never the equality operators." I know that "is"
is an identity operator, "==" and "!=" are the equality operators, but
I'm not sure what other singletons are being referred to here.

Also, I've seen code that does things like:

  if foo is 3:
  if foo is not '':

Are these valid uses of "is"?

Thanks in advance.
--
Steven.



More information about the Python-list mailing list