[Python-ideas] Fwd: Fwd: Fwd: unpacking generalisations for list comprehension
Paul Moore
p.f.moore at gmail.com
Mon Oct 17 16:27:32 EDT 2016
On 17 October 2016 at 21:22, Random832 <random832 at fastmail.com> wrote:
> For a more concrete example:
>
> [*range(x) for x in range(4)]
> [*(),*(0,),*(0,1),*(0,1,2)]
> [0, 0, 1, 0, 1, 2]
>
> There is simply no way to get there by using flatten(range(4)). The only
> way flatten *without* a generator expression can serve the same use
> cases as this proposal is for comprehensions of the *exact* form [*x for
> x in y]. For all other cases you'd need list(flatten(...generator
> expression without star...)).
Do you have a real-world example of needing this?
Paul
More information about the Python-ideas
mailing list