A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-November/136884.html below:

[Python-Dev] The role of NotImplemented: What is it for and when should it be used?

[Python-Dev] The role of NotImplemented: What is it for and when should it be used? [Python-Dev] The role of NotImplemented: What is it for and when should it be used?Antoine Pitrou solipsis at pitrou.net
Mon Nov 3 18:10:59 CET 2014
On Mon, 3 Nov 2014 09:05:43 -0800
Guido van Rossum <guido at python.org> wrote:
> Sorry, was too quick.  For immutable types __iop__ may not exist and then
> the fallback machinery should work normally using NotImplemented. But if
> __iop__ exists it can choose not to allow __rop__, because the type would
> presumably change. This is probably more predictable. I don't even know if
> the byte code interpreter looks for Not implemented from __iop__.

Apparently it can tell it to fallback on __op__:

>>> class C(list):
...   def __iadd__(self, other):
...     print("here")
...     return NotImplemented
... 
>>> c = C()
>>> c += [1]
here
>>> c
[1]
>>> type(c)
<class 'list'>


Regards

Antoine.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4