[Python-ideas] Adding collections.abc.Ordered
Ben Finney
ben+python at benfinney.id.au
Sat Dec 26 18:33:56 EST 2015
Guido van Rossum <guido at python.org> writes:
> 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.
Understood, thanks for explaining the difference.
> 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.
Oh, you mean setting the attribute so it's not a method at all but a
simple non-callable object? That makes sense.
Why recommend ‘None’, though? We now have the ‘NotImplemented’ object;
why not set the attribute of the class as ‘foo = NotImplemented’?
--
\ “We are stuck with technology when what we really want is just |
`\ stuff that works.” —Douglas Adams |
_o__) |
Ben Finney
More information about the Python-ideas
mailing list