On 19/06/2021 05:38, Steven D'Aprano wrote:
On Sat, Jun 19, 2021 at 03:30:05AM -0000, wyz2...@163.com 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 -- 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/6ERUPVCUFKYKHMT5CUNVRZ4ZRIBMNJSZ/
Code of Conduct: http://python.org/psf/codeofconduct/