<br><br>On Friday, April 27, 2018, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Apr 28, 2018 at 6:06 AM, Wes Turner <<a href="mailto:wes.turner@gmail.com">wes.turner@gmail.com</a>> wrote:<br>
><br>
><br>
> On Friday, April 27, 2018, Chris Angelico <<a href="mailto:rosuav@gmail.com">rosuav@gmail.com</a>> wrote:<br>
>><br>
>> On Fri, Apr 27, 2018 at 8:18 PM, Wes Turner <<a href="mailto:wes.turner@gmail.com">wes.turner@gmail.com</a>> wrote:<br>
>> > IDK, I could just be resistant to change, but this seems like something<br>
>> > that<br>
>> > will decrease readability -- and slow down code review -- without any<br>
>> > real<br>
>> > performance gain. So, while this would be useful for golfed-down (!)<br>
>> > one-liners with pyline,<br>
>> > I'm -1 on PEP 572.<br>
>><br>
>> PEP 572 has never promised a performance gain, so "without any real<br>
>> performance gain" is hardly a criticism.<br>
>><br>
>> > How do I step through this simple example with a debugger?<br>
>> ><br>
>> >     if re.search(pat, text) as match:<br>
>> >         print("Found:", match.group(0))<br>
>><br>
>> Step the 'if' statement. It will call re.search() and stash the result<br>
>> in 'match'. Then the cursor would be put either on the 'print' (if the<br>
>> RE matched) or on the next executable line (if it didn't).<br>
><br>
><br>
> Right. Pdb doesn't step through the AST branches of a line, so ternary<br>
> expressions and list comprehensions and defining variables at the end of the<br>
> line are 'debugged' after they're done.<br>
><br>
> Similarly, code coverage is line-based; so those expressions may appear to<br>
> be covered but are not.<br>
<br>
I'm not sure I follow. In what situation would some code appear to be<br>
covered when it isn't, due to an assignment expression?</blockquote><div><br></div><div>When an assignment expression is in the else clause of a ternary expression, but the else clause does not execute because the condition is true, the assignment expression does not execute and so isn't covered.</div><div><br></div><div>if ((1) or (x := 3)):</div><div>if ((y := func(x)) if x else (x := 3))</div><div><br></div><div>Is this a new opportunity for misunderstanding?</div><div><br></div><div>Assignment expressions, though they are noticeable :=, may not actually define the variable in cases where that part of the line doesn't run but reads as covered.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
ChrisA<br>
______________________________<wbr>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/wes.turner%40gmail.com" target="_blank">https://mail.python.org/<wbr>mailman/options/python-dev/<wbr>wes.turner%40gmail.com</a><br>
</blockquote>