It's certainly a contrived example. Actual code with such a mistake is generally far more subtle.<div><br></div><div>The mistake is that it's assigning a value within a clause of a conditional that won't be evaluated.</div><div><br></div><div>Oh well. I'll suffer the then worsened zig-zaggy eye movements in code reviews caused by defining values at the end of expressions that reference them which fit on a single line.</div><div><br></div><div>There are a number of bad examples for style guides in these threads.</div><div><br></div><div>:=</div><div><br></div><div>I wasn't aware of this switch, thanks!</div><div><a href="http://coverage.readthedocs.io/en/latest/branch.html">http://coverage.readthedocs.io/en/latest/branch.html</a></div><div>coverage run --branch code.py</div><div><br></div><div><br><br>On Friday, April 27, 2018, Tim Peters <<a href="mailto:tim.peters@gmail.com">tim.peters@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Wes, sorry, but I really don't follow what you're saying.  For example,<br>
<br>
[Wes Turner <<a href="mailto:wes.turner@gmail.com">wes.turner@gmail.com</a>>]<br>
> Do not do this:<br>
><br>
> x = 2<br>
> if (x == 3) or (x := 3):<br>
>    print(x)<br>
><br>
> What do we call that mistake?<br>
<br>
It displays 3 - while it appears to be silly code, there's nothing<br>
about it that's undefined.  So I fail to see how showing that example<br>
anywhere would do anyone any good.<br>
<br>
You can do the same kind of thing today via, e.g.,<br>
<br>
    class Bindable:<br>
        def __init__(self, value):<br>
            self.bind(value)<br>
<br>
        def bind(self, value):<br>
            self.value = value<br>
            return value<br>
<br>
        def __bool__(self):<br>
            return bool(self.value)<br>
<br>
        def __eq__(self, other):<br>
            return self.value == other<br>
<br>
        def __str__(self):<br>
            return str(self.value)<br>
<br>
Then:<br>
<br>
>>> x = Bindable(2)<br>
>>> if x == 3 or x.bind(3):<br>
...     print(x)<br>
3<br>
<br>
And I wouldn't put that example anywhere in any docs either ;-)<br>
</blockquote></div>