<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Oct 17, 2016 at 10:32 AM, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">But if we *do* accept this syntax, then I believe that we should drop<br>
the pretense that it is a natural extension of sequence unpacking in the<br>
context of a for-loop-with-append (i.e. list comprehensions) and accept<br>
that it will be seen by people as a magical "flatten" operator. [...]<br></blockquote><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">So, yet again for emphasis: I see what you mean about unrolling the list<br>comprehension into a list display. But I believe that's not a helpful<br>way to think about list comprehensions.</blockquote></div><div><br></div><div>Moreover, this "magical flatten" operator will crash in bad ways that a regular flatten() will not. I.e. this is fine (if strange):</div><div><br></div><div><div>>>> three_inf = (count(), count(), count())</div><div>>>> comp = (x for x in flatten(three_inf))</div></div><div>>>> next(comp)</div><div>0</div><div>>>> next(comp)</div><div>1 </div><div><br></div><div>It's hard to see how that won't blow up under the new syntax (i.e. generally for all infinite sequences).</div><div><br></div><div>Try running this, for example:</div><div><br></div><div>>>> a, *b = count()<br></div><div><br></div><div>Syntactically valid... but doesn't terminate.</div></div><div><br></div>-- <br><div class="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div>
</div></div>