[Python-ideas] Introduce collections.Reiterable
Ethan Furman
ethan at stoneleaf.us
Mon Sep 23 03:41:53 CEST 2013
On 09/22/2013 12:04 PM, Neil Girdhar wrote:
> I'm with you on this.
>
> If you want an Iterable and you wrote __getitem__, then it's not too much to ask that you either write a trivial __iter__:
If you want to be in full compliance, sure. But one of the nice things about Python is you aren't forced to write more
than you need. If I have objects that I want to have be equal to each other I can just write __eq__ -- I don't have to
write __lt__, __gt__, __le__, nor __ge__. And if I want to not equal to be the opposite of equal (as opposed to
something weird) I don't even need to write __ne__ any more.
> or you write __len__ and inherit from collections.Sequence.
I don't like inheriting from any of the abc's (maybe I just haven't written a large enough framework yet). And I'm not
writing __len__ unless I plan on supporting len().
> We should deprecate the sequence protocol.
No, we shouldn't.
--
~Ethan~
More information about the Python-ideas
mailing list