[Python-ideas] PEP 479: Change StopIteration handling inside generators
random832 at fastmail.us
random832 at fastmail.us
Wed Nov 26 14:59:34 CET 2014
On Tue, Nov 25, 2014, at 22:51, Juancarlo AƱez wrote:
> On Tue, Nov 25, 2014 at 5:26 PM, <random832 at fastmail.us> wrote:
>
> > def pairs(x):
> > i = iter(x)
> > while True:
> > yield next(i), next(i)
> >
>
> That's not too pythonic, and trying to support non-pythonic code while
> evolving the language is a dead-end street.
Out of curiosity, what explicit uses of next are pythonic?
> The web documents pythonic ways to obtain pairs from an iterable:
>
> def pairs(x):
> i = iter(x)
> return zip(i, i)
>
> Or even:
>
> def pairs(x):
> return zip(*[iter(x)]*2)
See, both of those seem way too implicit to me.
More information about the Python-ideas
mailing list