[Python-ideas] Adding collections.abc.Ordered
Guido van Rossum
guido at python.org
Sat Dec 26 18:30:23 EST 2015
No, raising NotImplementedError means that a subclass was supposed to
implement the method. In this case it's different -- it should appear as if
the method isn't implemented to code that checks for the method's presence.
Introspecting whether the code raises NotImplementedError is unfeasible. We
explicitly decided that setting the method to None indicates that it should
be considered as absent by code that checks for the method's presence.
On Sat, Dec 26, 2015 at 4:23 PM, Ben Finney <ben+python at benfinney.id.au>
wrote:
> Guido van Rossum <guido at python.org> writes:
>
> > There is a precedent for declaring that a method isn't implemented:
> > __hash__. The convention is to set it to None in the subclass that
> > explicitly doesn't want to implement it.
>
> Isn't ‘raise NotImplementedError’ the more explicit convention provided
> by Python (as a built-in, explicitly-named exception!) for communicating
> this meaning?
>
> --
> \ “[It's] best to confuse only one issue at a time.” —Brian W. |
> `\ Kernighan, Dennis M. Ritchie, _The C programming language_, 1988 |
> _o__) |
> Ben Finney
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151226/eb55b854/attachment-0001.html>
More information about the Python-ideas
mailing list