<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Apr 22, 2018 at 3:13 PM, Steve Dower <span dir="ltr"><<a href="mailto:steve.dower@python.org" target="_blank">steve.dower@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="#954F72" lang="EN-US"><div class="m_3307186343635555573WordSection1"><p class="MsoNormal">This example makes me want “if expr as name:” (same semantics as ‘with’, and the name is always bound to the expression result regardless of truthiness), but doesn’t move me on assignment expressions.</p></div></div></blockquote><div><br></div><div>In reality there often are other conditions being applied to the match for which `if expr as name` is inadequate. The simplest would be something like<br><br></div><div> if ...:<br></div><div> <something><br></div><div> elif (m := re.match('(.*):(.*)', line)) and m.group(1) == m.group(2):<br></div><div> <whatever><br></div><div><br></div><div>And the match() call may not even be the first thing to check -- e.g. we could have<br><br> elif line is not None and (m := re.match('(.*):(.*)', line)) and m.group(1) == m.group(2):<br></div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>