Hi Nick,

On Mon, Aug 30, 2021 at 4:25 PM Nick Parlante <n...@cs.stanford.edu> wrote:
> I don't know Chris, doesn't this just show that If you construct a class with 
> a, shall we say, "oddball" definition of ==, then using == on that class gets 
> oddball results. And it goes without saying that we all understand that None 
> and False and True (the dominant cases where PEP8 is forcing "is") will 
> always have sensible definitions of ==.

If you have `if x == None:`, you don't only have to care about whether
`None` has an "oddball" definition of ==, you also have to care about
whether the type of `x` does! Since in many of these cases `x` is
something passed in from outside the function, you may not have any
idea about or control over its type. That's why people are telling you
that almost all the occurrences you've found would in fact be unsafe
if changed from `is` to `==`, and it's very rare that you can
"eyeball" a particular case and declare confidently that it would be
fine to switch it from `is` to `==`.

Carl
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SUDREKWXWH4V5Z5NWC6GNHQHK5E6PKGL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to