<div dir="ltr">On 25 February 2013 02:08, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com" target="_blank">wlfraed@ix.netcom.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">On Sun, 24 Feb 2013 21:58:36 +0000, Joshua Landau<br>
<<a href="mailto:joshua.landau.ws@gmail.com" target="_blank">joshua.landau.ws@gmail.com</a>> declaimed the following in<br>
gmane.comp.python.general:<br>
<br>
<br>
><br>
<div>> condition1 = long_condition_expression_1<br>
> condition2 = long_condition_expression_2<br>
> condition3 = long_condition_expression_3<br>
><br>
> if condition1 and condition2 and condition3:<br>
>     STUFF<br>
><br>
> No multiline needed. If you have *many* conditions, then:<br>
><br>
</div>        Except that Python does short-circuit evaluation; your scheme will<br>
fail in some situations:<br>
<br>
>>> x = 0<br>
>>> if x != 0 and 32 / x > 4:<br>
...     print "we passed"<br>
...<br>
>>> c1 = x != 0<br>
>>> c2 = 32 / x > 4<br>
Traceback (most recent call last):<br>
  File "<interactive input>", line 1, in <module><br>
ZeroDivisionError: integer division or modulo by zero<br>
<div><div>>>><br>
</div></div></blockquote></div><br></div><div class="gmail_extra">Yeah, well... context*.</div><div class="gmail_extra"><br></div><div class="gmail_extra">There are perfectly legitimate ways of doing that too.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">A simple one would be:</div><div class="gmail_extra"><br></div><div class="gmail_extra">> supercondition = (</div><div class="gmail_extra">
>     <span style="color:rgb(80,0,80)">long_condition_expression_1 and</span></div><div class="gmail_extra">>     <span style="color:rgb(80,0,80)">long_condition_expression_2 and</span><span style="color:rgb(80,0,80)"><br>


</span></div><div class="gmail_extra">>     <span style="color:rgb(80,0,80)">long_condition_expression_3</span><span style="color:rgb(80,0,80)"><br></span></div><div class="gmail_extra">> )</div><div class="gmail_extra">


></div><div class="gmail_extra">> if supercondition: ...</div><div class="gmail_extra"><br></div><div class="gmail_extra">Please note the problem of the original is that the indentation dedents and indents in too quick a sequence:</div>


<div class="gmail_extra"><br></div><div class="gmail_extra">> if (</div><div class="gmail_extra">> something_here): # Where do I indent this to?</div><div class="gmail_extra">>     something_else</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">There are standards, but I don't like the style. I thought it worth mentioning as we were all being subjective anyway ;P. It's much worse than:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">> if something_here: something_else #on the same line</div><div class="gmail_extra"><br></div><div class="gmail_extra">which is already explicitly advised against.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra" style>* By which I mean: fair point</div>
</div>