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

Steve Barnes gadgetsteve at live.co.uk
Tue Nov 28 01:00:58 EST 2017



On 27/11/2017 21:49, Guido van Rossum wrote:
> On Mon, Nov 27, 2017 at 1:32 PM, Chris Angelico <rosuav at gmail.com 
> <mailto:rosuav at gmail.com>> wrote:
> 
>     On Tue, Nov 28, 2017 at 8:24 AM, Guido van Rossum <guido at python.org
>     <mailto:guido at python.org>> wrote:
>     > On Mon, Nov 27, 2017 at 1:18 PM, Greg Ewing <greg.ewing at canterbury.ac.nz <mailto: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 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 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 until 3.8.
> 
> -- 
> --Guido van Rossum (python.org/~guido 

Can we please take a note to ensure any future PEP clearly states which 
ellipsis (personally I prefer the first) of:

  - as 3 consecutive full stop characters (U+002E) i.e. ...
  - the Chicago system of 3 space separated full stops . . .
  - Unicode Horizontal ellipsis (U+2026) (at least there is a keyboard 
short cut for this) …
  - Unicode Midline horizontal ellipsis (U+22EF) ⋯
  - any of the other ellipsis characters 
(https://en.wikipedia.org/wiki/Ellipsis#Computer_representations)

As clarifying this early could save a lot of later discussion such as 
the recent minus, hyphen, underscore debate.

-- 
Steve (Gadget) Barnes
Any opinions in this message are my personal opinions and do not reflect 
those of my employer.

---
This email has been checked for viruses by AVG.
http://www.avg.com



More information about the Python-ideas mailing list