Continuing indentation

Ben Finney ben+python at benfinney.id.au
Wed Mar 2 16:29:27 EST 2016


Skip Montanaro <skip.montanaro at gmail.com> writes:

> Running flake8 over some code which has if statements with multiple
> conditions like this:
>
>     if (some_condition and
>         some_other_condition and
>         some_final_condition):
>         play_bingo()
>
> the tool complains that the indentation of the conditions is the same
> as the next block.

For this reason I prefer to indent all continuation lines 8 spaces::

    if (
            some_condition and
            some_other_condition and
            some_final_condition):
        play_bingo()

> I use GNU Emacs as my text editor, and its python mode.  I'm pretty
> happy with everything (been using it in its current state for several
> years).  Aside from manually or configure-ologically suppressing E129,
> is there a better way to break lines I'm missing which will make
> flake8 happy?

The style I recommend above is PEP 8 compliant, easy to read, remember,
and apply.

-- 
 \     “This [Bush] Administration is not sinking. This Administration |
  `\   is soaring. If anything they are rearranging the deck chairs on |
_o__)                     the Hindenburg.” —Steven Colbert, 2006-04-29 |
Ben Finney




More information about the Python-list mailing list