On 19/06/2021 05:38, Steven D'Aprano wrote:
On Sat, Jun 19, 2021 at 03:30:05AM -0000, [email protected] wrote:

Python raises TypeError when NotImplemented is returned from __add__,
__invert__ etc. and __radd__ etc. aren't available.
Roughly correct. It's more complex than that.

I just wanted to add that NotImplemented is *only* for binary (and binary comparison) operators.

https://docs.python.org/3/library/constants.html?highlight=notimplemented#NotImplemented

Ok, also when __length_hint__ can't help. Generally though, other contexts from which the special method might be called do not check for it.

--

Jeff Allen

_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/6ERUPVCUFKYKHMT5CUNVRZ4ZRIBMNJSZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to