Ethan Furman added the comment:

Thank you, Raymond, both for your concern and your discretion.

My interest in changing the "can" or "may" to "should" is that, whatever the 
original intent of the PEP, the way Python works /now/ is that any class that 
doesn't return NotImplemented when it /should/ is not going to interoperate 
well with other compatible classes.

At the heart of the issue is what happens when

  def bin_op(self, other):
     ...

is called, but the left-hand operand doesn't know how to work with the 
right-hand operand?

We have three choices:

  - do nothing, letting any exceptions boil up or errors propagate

  - do a check on 'other' to determine if it's usable, and raise an exception
    if it is not

  - do a check on 'other' to determine if it's usable, and return NotImplemented
    if it is not

Only the last choice allows 'other' to also try the operation.  Except for the 
special-case of in-place bin-ops, why would we not want choice three?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22780>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to