On Tue, Feb 9, 2010 at 7:58 PM, Daniel Stutzbach <span dir="ltr"><<a href="mailto:daniel@stutzbachenterprises.com">daniel@stutzbachenterprises.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><div class="gmail_quote">On Tue, Feb 9, 2010 at 9:36 PM, Tim Chase <span dir="ltr"><<a href="mailto:python.list@tim.thechases.com" target="_blank">python.list@tim.thechases.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
removing the "not" from the condition.  I admit I choose one over the other based on some gut-feeling aesthetic that I can't really nail down.  I think one of my major influencing factors revolves around the negative "not" portion having one or two lines and the  positive portion having a large block of code.  </blockquote>


<div><br></div></div></div>If one block is much shorter, I tend to put the shorter block first.  That way, the "else" and the "if" are almost always on the screen together at the same time.  If they're both long, I factor out one or both of the blocks into functions.<br>

</blockquote><div><br></div><div>Agree 100%.</div><div><br></div><div>I like whatever the little branch is to be first, with the big branch falling into the "else:". It reads better then to have an "else:" at the end with only a line or two: in such a situation what 'else' is doesn't really have direct meaning, you have to look too far up to connect it to the "if" logic. Comments shouldn't be needed-- if an "else:" falls too far away from the "if" then scrolling around and looking for the code, it won't be immediately obvious in meaning.</div>

<div><br></div><div>And if both branches are fairly long, it tends to imply that I just might benefit from some more functions to re-organize logic into manageable chunks. Then again, general rule of thumb? If a function is not entirely visible on my screen, it might imply I might benefit from some more functions. Though this is not anything like a hard rule.</div>

<div><br></div></div><div name="mailplane_signature">--S</div>