[Python-ideas] Fwd: unpacking generalisations for list comprehension
Rob Cliffe
rob.cliffe at btinternet.com
Tue Oct 25 20:25:48 EDT 2016
On 14/10/2016 07:00, Greg Ewing wrote:
> Neil Girdhar wrote:
>> At the end of this discussion it might be good to get a tally of how
>> many people think the proposal is reasonable and logical.
>
> I think it's reasonable and logical.
>
I concur. Two points I personally find in favour, YMMV:
(1) [*subseq for subseq in seq] avoids the "conceptual hiatus" I
described earlier in [elt for subseq in seq for elt in subseq]
(I.e. I think the case for the proposal would be weaker if the
loops in a list comprehension were written in reverse order.)
(2) This is admittedly a somewhat tangential argument, but: I didn't
really know what "yield from" meant. But when I read in an earlier post
that someone had proposed "yield *" for it, I had a Eureka moment.
Which suggests if "*" is used to mean some sort of unpacking in more
contexts, the more familiar and intuitive it may become. I guess the
word I'm groping for is 'consistency'.
Rob Cliffe
More information about the Python-ideas
mailing list