[Python-ideas] Integrate some itertools into the Python syntax

Chris Angelico rosuav at gmail.com
Tue Mar 22 09:05:56 EDT 2016


On Tue, Mar 22, 2016 at 11:58 PM, Michel Desmoulin
<desmoulinmichel at gmail.com> wrote:
> E.G: I suggested before that iter() returns objects with advanced
> semantics for [:] as an alternative to add slicing to generators.

The builtin iter() function simply returns whatever __iter__()
returns. I've offered a way for you to easily shadow the builtin with
your own class (which can then provide whatever it likes), but it's
going to have to work by wrapping the original iterator, which will
break generators (unless you explicitly pass everything through, and
even then you'll break things that check if isinstance(x, generator),
because you can't subclass generator).

ChrisA


More information about the Python-ideas mailing list