<div dir="ltr"><br><div class="gmail_quote"><div dir="ltr">[Nick Coghlan]</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
However, PEP 572 in its current form takes the position "parent local<br>
scoping is sufficiently useful to make it a required pre-requisite for<br>
adding assignment expressions, but not useful enough to expose as a<br>
new scope declaration primitive",<br></blockquote><div><br>Of course the PEP doesn't take that position at all:  it doesn't even contain the term "parent local scoping".  That's your term, which nobody else uses unless they're replying to you ;-)<br><br>What the PEP does say:<br><br>"""<br>

<font face="arial, helvetica, sans-serif" size="2"><span style="color:rgb(68,68,68);background-color:rgb(249,249,249);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">an assignment expression occurring in a list, set or dict comprehension or in a generator expression (below collectively referred to as "comprehensions") binds the target in the containing scope, honoring a </span><tt class="gmail-docutils gmail-literal" style="box-sizing:border-box;color:rgb(68,68,68);background-color:rgb(249,249,249);text-decoration-style:initial;text-decoration-color:initial">nonlocal</tt><span style="color:rgb(68,68,68);background-color:rgb(249,249,249);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>or<span> </span></span><tt class="gmail-docutils gmail-literal" style="box-sizing:border-box;color:rgb(68,68,68);background-color:rgb(249,249,249);text-decoration-style:initial;text-decoration-color:initial">global </tt><span style="color:rgb(68,68,68);background-color:rgb(249,249,249);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">declaration for the target in that scope, if one exists. For the purpose of this rule the containing scope of a nested comprehension is the scope that contains the outermost comprehension. A lambda counts as a containing scope.</span>

</font><br>"""<br><br>It's a small collection of plainly stated rules for specifying the intended semantics.  If you want to claim that this _is_ "useful enough to expose as a new scope declaration primitive", it's really on you to present use cases to justify that claim.  I'd present some for you, but I don't have any (I don't care that "by hand" conversion of nested comprehensions to workalike Python nested functions may require a bit of thought to establish the intended scope of assignment expression target names - all of which is easily doable without adding any new statements).<br><br>I don't _expect_ that other good use cases exist.  The gimmick's purpose is to make code that visually _appears_ to belong to a block act as if embedded assignments do occur in that block.  If there's an explicitly nested function, that fundamental motivation no longer applies.</div></div></div>