"is" and "=="

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Thu Mar 13 08:55:50 CET 2003

> From: Dagur Páll Ammendrup [mailto:dagurp at heimsnet.is]
> Ah ok, I wish it was the same as ==, it just looks nicer :-)

If they did the same thing, there would be no point having two operators.

'is' and '==' test for different things. '==' should be a superset of 'is' - if two names refer to the same object then they should[1] compare equal. OTOH, just because two objects compare equal does not mean that they are the same object.

[1] It is technically possible to make an object compare unequal to itself, but there is almost never any sane reason to do this.

Tim Delaney

More information about the Python-list mailing list