[Python-ideas] How assignment should work with generators?

Serhiy Storchaka storchaka at gmail.com
Mon Nov 27 17:17:18 EST 2017

27.11.17 23:24, Guido van Rossum пише:
> Is this problem really important enough that it requires dedicated 
> syntax? Isn't the itertools-based solution good enough? (Or failing 
> that, couldn't we add something to itertools to make it more readable 
> rather than going straight to new syntax?)

I want to remind PEP 204 and PEP 212. The special purposed syntaxes were 
proposed to help solving much more common problems. They were rejected 
in favor of builtins range() and enumerate(). And we are happy with 
these builtins.

The function for solving this problem already exists. It's 
itertools.islice(). It isn't builtin, but this problem is much less 
common than use cases for range() and enumerate().

If we don't have special non-function syntax for range(), enumerate(), 
zip(), itertools.chain(), itertools.count(), itertools.repeat(), etc, I 
don't think we should have a special syntax for one particular case of 
using itertools.islice().

More information about the Python-ideas mailing list