[Python-ideas] How assignment should work with generators?
Guido van Rossum
guido at python.org
Mon Nov 27 16:49:25 EST 2017
On Mon, Nov 27, 2017 at 1:32 PM, Chris Angelico <rosuav at gmail.com> wrote:
> On Tue, Nov 28, 2017 at 8:24 AM, Guido van Rossum <guido at python.org>
> > On Mon, Nov 27, 2017 at 1:18 PM, Greg Ewing <greg.ewing at canterbury.ac.nz
> > wrote:
> >> Chris Angelico wrote:
> >>> The problem is that it depends on internal whitespace to
> >>> distinguish it from augmented assignment;
> >> Ah, didn't spot that. I guess the ellipsis is the next best
> >> thing then.
> >> An alternative would be to require parens:
> >> (x, y, *) = z
> > But that would have the same issue.
> > Is this problem really important enough that it requires dedicated
> > Isn't the itertools-based solution good enough? (Or failing that,
> > we add something to itertools to make it more readable rather than going
> > straight to new syntax?)
> I don't think there's much that can be done without syntax; the
> biggest problem IMO is that you need to tell islice how many targets
> it'll be assigned into. It needs some interpreter support to express
> "grab as many as you have targets for, leaving everything else behind"
> without stating how many that actually is. So the question is whether
> that is sufficiently useful to justify extending the syntax. There are
> a number of potential advantages and several competing syntax options,
> and this suggestion keeps coming up, so I think a PEP is warranted.
OK, that's reasonable, and at first blush the ellipsis proposal looks okay.
My PEP queue for Python 3.7 is full though, so I would like to put this off
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas