[Python-ideas] Adding collections.abc.Ordered

Ben Finney ben+python at benfinney.id.au
Sat Dec 26 19:21:00 EST 2015


Guido van Rossum <guido at python.org> writes:

> On Sat, Dec 26, 2015 at 4:33 PM, Ben Finney <ben+python at benfinney.id.au>
> wrote:
>
> > Why recommend ‘None’, though? We now have the ‘NotImplemented’
> > object; why not set the attribute of the class as ‘foo =
> > NotImplemented’?
>
> Too late by many language releases, and not worth fixing.

Yes, to be clear I'm not suggesting a change of ‘__hash__ = None’.

I am talking of new code, like the changes being discussed in this
thread: since we have ‘NotImplemented’ now, we can more explicitly
indicate not-implemented attributes with ‘foo = NotImplemented’.

> Either way it's an arbitrary token that you would have to check for
> specially and whose meaning you'd have to look up. Also,
> NotImplemented has very special semantics (its main use is for
> *binary* operators to indicate "not overloaded on this argument, try
> the other") -- this has nothing to do with that.

Okay, that's clear. Semantics can change over time, though, and I think
‘NotImplemented’ much more clearly indicates the desired semantics than
‘None’, and is not ambiguous with existing uses of ‘foo = None’ on a
class.

So I advocate a class-level ‘foo = NotImplemented’ as an obvious way to
indicate an expected method is not implemented on this class.

Thanks for discussing and explaining. My vote counts for whatever it
counts for, and I'll let these arguments stand or fall as I've presented
them.

-- 
 \                “Every sentence I utter must be understood not as an |
  `\                      affirmation, but as a question.” —Niels Bohr |
_o__)                                                                  |
Ben Finney



More information about the Python-ideas mailing list