[Python-ideas] Introduce collections.Reiterable
mistersheik at gmail.com
Sun Sep 22 21:04:46 CEST 2013
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__:
def __iter__(self): return (self.__getitem__(i) for i in itertools.count())
or you write __len__ and inherit from collections.Sequence.
We should deprecate the sequence protocol.
On Sun, Sep 22, 2013 at 12:37 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 9/22/2013 10:22 AM, Nick Coghlan wrote:
> The __getitem__ fallback is a backwards
>> compatibility hack, not part of the formal definition of an iterable.
> When I suggested that, by suggesting that the fallback *perhaps* could be
> called 'semi-deprecated, but kept for back compatibility' in the glossary
> entry, Raymond screamed at me and accused me of trying to change the
> language. He considers it an intended language feature that one can write a
> sequence class and not bother with __iter__. I guess we do not all agree
> Terry Jan Reedy
> Python-ideas mailing list
> Python-ideas at python.org
> --- You received this message because you are subscribed to a topic in the
> Google Groups "python-ideas" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/**
> To unsubscribe from this group and all its topics, send an email to
> python-ideas+unsubscribe@**googlegroups.com<python-ideas%2Bunsubscribe at googlegroups.com>
> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas