25.07.19 22:05, Kyle Stanley пише:
I would agree that a doc change should occur if it is decided that the current behavior 
is appropriate, but I would like to mention that in the current [documentation for 
`object.__eq__()`](https://docs.python.org/3/reference/datamodel.html#object.__eq__), it 
states: "A rich comparison method may return the singleton `NotImplemented` if it 
does not implement the operation for a given pair of arguments".

Wouldn't returning `NotImplemented` be far more explicit to the user, in terms 
to directly telling them that the equality assessment between two dictionary 
views is not implemented? In general, I find this to be far more informative 
than simply returning False. At a surface level, users may assume that False 
would imply that there was an actual assessment of equality being performed.

This may not be an established precedent for other similar equality 
assessments, but I don't think the `NotImplemented` constant is utilized as 
much as it could be. It seems to be particularly well suited for addressing 
this situation.

NotImplemented is returned by the `__eq__` method, but the `==` operator returns False. Do not confuse them.

  >>> {}.values().__eq__({}.values())
  NotImplemented
  >>> {}.values() == {}.values()
  False

Actually, the `==` operator cannot return NotImplemented.
_______________________________________________
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/JLSKYYX5SU6VLNEVGVITUDCI3NRWALFS/

Reply via email to