On Mon, Oct 17, 2016 at 10:32 AM, Steven D'Aprano firstname.lastname@example.org wrote:
But if we *do* accept this syntax, then I believe that we should drop the pretense that it is a natural extension of sequence unpacking in the context of a for-loop-with-append (i.e. list comprehensions) and accept that it will be seen by people as a magical "flatten" operator. [...]
So, yet again for emphasis: I see what you mean about unrolling the list
comprehension into a list display. But I believe that's not a helpful way to think about list comprehensions.
Moreover, this "magical flatten" operator will crash in bad ways that a regular flatten() will not. I.e. this is fine (if strange):
three_inf = (count(), count(), count()) comp = (x for x in flatten(three_inf)) next(comp)
It's hard to see how that won't blow up under the new syntax (i.e. generally for all infinite sequences).
Try running this, for example:
a, *b = count()
Syntactically valid... but doesn't terminate.