Result of ``a is b''

Asun Friere afriere at
Wed Mar 17 04:53:29 CET 2004

Skip Montanaro <skip at> wrote in message news:<mailman.52.1079472192.742.python-list at>...

> No, its behavior is quite well-specified.  It does a pointer comparison.
> Here is my "is" rule:
>     Use "is" to compare two objects only if one is explicitly known to be a
>     singleton defined by the language (None, Ellipsis, True, False).
> and its corrolary:
>     Never use "is" to compare two programmer-defined variables.
What about when it is an object explicitly known to be singleton
defined by the programmer. ;)

Another possible use, would be to type test, eg.  'foo.__class__ is
Foo', bearing in mind that one should avoid type testing in favour of

More information about the Python-list mailing list