Serhiy Storchaka wrote:
> Is there any precedence of raising an exception in the equality comparison?
> Does 3 == "3" returning False make more sense to you?

Personally, I don't find ``3 == "3"`` to be an equivalent comparison to 
``d0.values() == d1.values()``. Generally, it makes sense when comparing two 
items of different types, they are not going to be equivalent (except in cases 
such as ``3 == 3.0``, but in that case they are both subtypes of numeric). 

I don't know that an exception would be the best behavior to suit this 
situation (or for anything using ``__eq__`` for that matter), but returning 
``False`` seems to be a bit misleading. Instead, I think that either returning 
the ``NotImplemented`` constant or ``None`` would provide far more useful 
information to the user, without the hindrance of causing an exception. I'm 
leaning more favorably towards ``NotImplemented`` because it explicitly tells 
the user "Hey, that equality comparison isn't implemented".
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/SJKDNGBIEBCL67NWL7CPGTVNSY2QLXBD/

Reply via email to