> For a more concrete example:
> [*range(x) for x in range(4)]
> [0, 0, 1, 0, 1, 2]
As Paul or someone pointed out, that's a fairly odd thing to do. It's the
first time that use case has been mentioned in this thread. It's true
you've managed to construct something that isn't done by flatten(). I
would have had to think a while to see what you meant by the original if
you haven't provided the intermediate interpretations.
Of course, it's *really simple* to spell that in a natural way with
existing syntax that isn't confusing like yours:
[x for end in range(4) for x in range(end)]
There is no possible way to construct something that would use the proposed
syntax that can't be expressed more naturally with a nested loop... because
it's just confusing syntax sugar for exactly that.
Your example looks like some sort of interview quiz question to see if
someone knows obscure and unusual syntax.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/