On Tue, Nov 25, 2014, at 22:51, Juancarlo Añez wrote:
On Tue, Nov 25, 2014 at 5:26 PM, firstname.lastname@example.org 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)
def pairs(x): return zip(*[iter(x)]*2)
See, both of those seem way too implicit to me.