On 18 October 2012 12:05, Tim Chase <span dir="ltr"><<a href="mailto:python.list@tim.thechases.com" target="_blank">python.list@tim.thechases.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">On 10/18/12 04:33, <a href="mailto:wxjmfauth@gmail.com">wxjmfauth@gmail.com</a> wrote:<br>
> I use a "double indentation".<br>
><br>
>>>> if 'asdf' and 'asdf' and 'asdf' \<br>
> ...         'asdf' and 'asdf' and \<br>
> ...         'asdf' and 'asdf':<br>
> ...     print('do if')<br>
> ...     s = 'asdf'<br>
> ...     ss = 'asdf'<br>
> ...<br>
> do if<br>
>>>> if looks_like_it_might_be_spam(<br>
> ...         some_longer_variables,<br>
> ...         here_and_here, and_here_also):<br>
> ...     logger.notice("might be spam")<br>
> ...     move_to_spam_folder(some_longer_variables)<br>
> ...     update_spam_statistics(here_and_here)<br>
<br>
</div>I lean towards double-indent as well, though I favor parens/brackets<br>
vs. trailing backslashes.  My conditions usually go one-per-line,<br>
too.  I also tend to put my closing paren+colon on a stand-alone line:<br>
<br>
    if (<br>
            something<br>
            or something_else<br>
            or yet_other_stuff<br>
            ):<br>
        do_thing1()<br>
        do_thing2()<br>
<br>
It's not quite as nice with pure parens, working better with<br>
function-calls.  However, it makes my git/svn diffs easier to read<br>
when conditions get added/removed because only that line (usually)<br>
changes, rather than having the noise of the paren moving around.<br>
<br>
In 2.5 and later, I like to write that as<br>
<br>
    if any([<br>
            something,<br>
            something_else,<br>
            yet_other_stuff,<br>
            ]):<br>
        do_thing1()<br>
        do_thing2()<br>
<br>
where each item is uniform (one trailing comma, rather than one item<br>
being special without a comma/or/and) so I don't have the diff noise<br>
for "or"/"and" bouncing around either.<br>
<br>
Making my diffs easy to read is pretty important to me.<br></blockquote><div><br></div><div>I'm of the opinion that:</div><div><br></div><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">

<font face="courier new, monospace">cheese_cake = bake( </font></blockquote><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">

<font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">     </span>self_raising_flour(),</font></blockquote><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">

<font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">     </span>sour_lemons(),</font></blockquote><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">

<font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">     </span>milky_cheese(),</font></blockquote><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">

<font face="courier new, monospace"> )</font></blockquote><div><br></div><div>is the nicest format for normal overflow, but I'm really irked at the sight of <i>any</i> overflow in an "if x:" statement or anything that starts more indentation. All indentation <i>and</i> outdentation should be meaningful: "group" or "end group" respectively. If you indent and then outdent <i>to a new indentation</i>, it's confusing and obfuscating. The outdent is not "end group", as before, but something else.</div>

<div><br></div><div>The neat thing about:</div><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"><font face="courier new, monospace">foobars = inversed_word_order( </font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>barfoo(),</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>raboof( </font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>inverse_mode="letters",</font> </blockquote>

<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"> <span class="Apple-tab-span" style="font-family:'courier new',monospace;white-space:pre">       </span><span class="Apple-tab-span" style="font-family:'courier new',monospace;white-space:pre">        </span>hidden_lettuce=GGE_RETSAE</blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>),</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>not foobar()</font></blockquote>

<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"><font face="courier new, monospace"> )</font></blockquote>

<div>is that it is consistent with this world-view.</div><div><br></div><div>My lines often go past 120 characters without splitting*, so I rarely have this problem, but when I do the solution is <i>invariably</i>:</div>
<div>
<br></div><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"><font face="courier new, monospace">all_can_be_baked = all(</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>can_be_baked(ingredient) </font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>for ingredient in [</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>self_raising_flour(),</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>sour_lemons(),</font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>milky_cheese(), </font></blockquote>

<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"><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>] </font></blockquote>

<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"><font face="courier new, monospace">) </font></blockquote>

<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"><font face="courier new, monospace"> </font></blockquote>
<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">
<font face="courier new, monospace">if all_can_be_baked:</font></blockquote><div><br></div><div>There is not a situation in the world where a suitable intermediate name can not be found: you are doing something for a reason, after all.</div>

<div><br></div><div>* I use 8-space tabs, so it's not that hard ;)</div></div>