[Python-ideas] Introduce collections.Reiterable

Neil Girdhar 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.

Neil


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
> https://mail.python.org/**mailman/listinfo/python-ideas<https://mail.python.org/mailman/listinfo/python-ideas>
>
> --
>
> --- 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/**
> topic/python-ideas/**OumiLGDwRWA/unsubscribe<https://groups.google.com/d/topic/python-ideas/OumiLGDwRWA/unsubscribe>
> .
> 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...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130922/b2a91153/attachment.html>


More information about the Python-ideas mailing list