Reference

Chris Angelico rosuav at gmail.com
Mon Mar 3 23:27:26 CET 2014


On Tue, Mar 4, 2014 at 9:22 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> You generally use "==" if more than one object could be equal. If you
> know there's only one object of the kind, you convey that knowledge by
> the use of "is" even when functionally, it doesn't matter.

It's even simpler than that.

You use "==" when you care about value, and "is" when you care about identity.

This is because "==" tests value, and "is" tests identity.

I do not understand why there is confusion.

ChrisA



More information about the Python-list mailing list