<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Conclusions<br>
------------<br>
<br>
It appears assignment expressions are no longer the favored solution for the<br>
"assign and compare" use case.  Not one of these five newer languages supports<br>
them fully, as the language generations from C to C# did.<br>
<br>
Of those that have recognized the use case to be large enough—the solution has<br>
been rather more limited to the "if" and "while" statements only.  Several<br>
folks here have expressed the same desire to confine AE there.  Since Python's<br>
design goals are similar—to be safe and maintainable I'd recommend a similar<br>
strategy, with the addition of the list comprehension case.  Going back to the<br>
C-style solution seems like the wrong direction.<br>
<br>
Since that would mean this special assignment functionality is not allowed to<br>
be used everywhere, it alleviates the pressure to make it fit into<br>
with/import/except statements.  Furthermore, that frees up the keyword "as"<br>
again, which is Pythonic, short, memorable and has a history of being used for<br>
various assignment purposes, not to mention a prominent feature of SQL.<br>
<br>
In short, extend the "if/elif", "while", and comprehension to:<br>
<br>
    if pattern.search(data) as match:<br>
        …<br>
<br>
    while read_next_item() as value:<br>
        …<br>
<br>
May be best to disallow multiple assignment/conditions for now, but up for<br>
discussion.  That leaves comprehensions, which could support a EXPR as NAME<br>
target also:<br>
<br>
    filtered_data = [f(x) as y, x/y for x in data]<br>
<br>
or perhaps reuse of the if…as statement to keep it simpler:<br>
<br>
    filtered_data = [y, x/y for x in data if f(x) as y]<br>
<br>
That variant might need an extra test if f(x) returns a falsey value, perhaps<br>
"is not None" on the end.<br>
<br>
Thoughts?<br>
-Mike<br></blockquote><div><br></div><div>Thanks for the research! </div></div><div class="gmail_extra"><br></div>Which is the niche, and how influential can it be, to have Python divert from the well learned "assignments must be statements".<br clear="all"><div><br></div><div>Cheers!</div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><span style="color:rgb(0,102,0)">Juancarlo </span><b style="color:rgb(0,102,0)">Añez</b></div>
</div></div>