<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"> [*t for t in [(1, 'a'), (2, 'b'), (3, 'c')]]<br></span></blockquote><div><br></div><div>Another problem with this is that it is very hard to generalize to the case where the item included in a comprehension is a transformation on iterated values. E.g. what does this do?</div><div><br></div><div> [math.exp(*t) for t in [(1,2),(3,4)]]</div><div><br></div><div>Maybe that somehow magically gets us:</div><div><br></div><div> [2.7182, 7.38905, 20.0855, 54.5981] </div><div> </div><div>Or maybe the syntax would be:</div><div><br></div><div> [*math.exp(t) for t in [(1,2),(3,4)]]</div><div><br></div><div>Neither of those follows conventional Python semantics for function calling or sequence unpacking. So maybe that remains a type error or syntax error. But then we exclude a very common pattern of using comprehensions to create collections of *transformed* data, not simply of filtered data.</div><div><br></div><div>In contrast, either of these are unambiguous and obvious:</div><div><br></div><div> [math.exp(t) for t in flatten([(1,2),(3,4)])]<br></div><div><br></div><div>Or:</div><div><br></div><div> [math.exp(n) for t in [(1,2),(3,4)] for n in t]</div><div><br></div><div>Obviously, picking math.exp() is arbitrary and any unary function would be the same issue.</div><div><br></div><div><br></div></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>