On Mon, Oct 17, 2016 at 10:32 AM, Steven D'Aprano <st...@pearwood.info>
> 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))
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.
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/