'==' vs. 'is' behavior

Fredrik Lundh fredrik at pythonware.com
Tue Nov 30 03:03:09 EST 1999


François Pinard <pinard at iro.umontreal.ca> wrote:
> By the way, is there common wisdom (or rather, maybe, usage-standards-to-be)
> about using `is' instead of `=='?

according to the eff-bot:

    foo is None
    type(foo) is type(bar) # same type
    foo is bar # same instance

use '==' for everything else (unless you know what
you're doing, of course).

</F>





More information about the Python-list mailing list