<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sat, Oct 15, 2016 at 5:01 AM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Oct 13, 2016 at 01:30:45PM -0700, Neil Girdhar wrote:<br class="gmail_msg">
<br class="gmail_msg">
> From a CPython implementation standpoint, we specifically blocked this code<br class="gmail_msg">
> path, and it is only a matter of unblocking it if we want to support this.<br class="gmail_msg">
<br class="gmail_msg">
I find that difficult to believe. The suggested change seems like it<br class="gmail_msg">
should be much bigger than just removing a block. Can you point us to<br class="gmail_msg">
the relevant code?<br class="gmail_msg">
<br class="gmail_msg"></blockquote><div><br></div><div>The Grammar specifies:</div><div><br></div><div><div>dictorsetmaker: ( ((test ':' test | '**' expr)</div><div>                   (comp_for | (',' (test ':' test | '**' expr))* [','])) |</div><div>                  ((test | star_expr)</div><div>                   (comp_for | (',' (test | star_expr))* [','])) )</div></div><div><br></div><div>In ast.c, you can find:</div><div><br></div><div><div>                if (is_dict) {</div><div>                    ast_error(c, n, "dict unpacking cannot be used in "</div><div>                            "dict comprehension");</div><div>                    return NULL;</div><div>                }</div><div>                res = ast_for_dictcomp(c, ch);</div></div><div><br></div><div>and ast_for_dictcomp supports dict unpacking.</div><div><br></div><div>Similarly:</div><div><br></div><div><div>    if (elt->kind == Starred_kind) {</div><div>        ast_error(c, ch, "iterable unpacking cannot be used in comprehension");</div><div>        return NULL;</div><div>    }</div><div><br></div><div>    comps = ast_for_comprehension(c, CHILD(n, 1));</div></div><div><br></div><div>and ast_for_comprehensions supports iterable unpacking.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In any case, it isn't really the difficulty of implementation that is<br class="gmail_msg">
being questioned. Many things are easy to implement, but we still<br class="gmail_msg">
don't do them. </blockquote><div><br></div><div>If it doesn't matter, why bring it up?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The real questions here are:<br class="gmail_msg">
<br class="gmail_msg">
(1) Should we overload list comprehensions as sugar for a flatten()<br class="gmail_msg">
function?<br class="gmail_msg">
<br class="gmail_msg">
(2) If so, should we spell that [*t for t in iterable]?<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Actually the answer to (1) should be "we already do". We just spell it:<br class="gmail_msg">
<br class="gmail_msg">
    [x for t in iterable for x in t]<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Steve<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Python-ideas mailing list<br class="gmail_msg">
<a href="mailto:Python-ideas@python.org" class="gmail_msg" target="_blank">Python-ideas@python.org</a><br class="gmail_msg">
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" class="gmail_msg" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br class="gmail_msg">
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" class="gmail_msg" target="_blank">http://python.org/psf/codeofconduct/</a><br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
<br class="gmail_msg">
---<br class="gmail_msg">
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br class="gmail_msg">
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/ROYNN7a5VAc/unsubscribe" rel="noreferrer" class="gmail_msg" target="_blank">https://groups.google.com/d/topic/python-ideas/ROYNN7a5VAc/unsubscribe</a>.<br class="gmail_msg">
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" class="gmail_msg" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br class="gmail_msg">
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer" class="gmail_msg" target="_blank">https://groups.google.com/d/optout</a>.<br class="gmail_msg">
</blockquote></div></div>