PEP 8 and indentation of continuation lines

J

John Yeung

Lurking on python-dev, I noticed a thread early this month (starting
June 2) about possible additions to PEP 8 covering indentation of
continuation lines. The recommendation was to double-indent
continuation lines which are about to introduce a new suite, unless
you are going to base your indentation on the opening paren. Examples
from that thread include

def some_really_long_function_name(
an_argument,
another_argument,
and_a_third_argument):
foo()

if some_really_long_function_name(
an_argument,
another_argument,
and_a_third_argument):
foo()

So last week PEP 8 was updated to reflect this. All fine and good. I
happen to prefer this style myself. But there remains an example
further down (left over from earlier incarnations of PEP 8) which
might go against this:

if (width == 0 and height == 0 and
color == 'red' and emphasis == 'strong' or
highlight > 100):
raise ValueError("sorry, you lose")

The above satisfies the "opening paren" alignment, but due to the
length of the keyword, the suite is obscured. For this example,
should PEP 8 use the double-indentation for the continuation lines?
(There was also discussion of this in a comp.lang.python thread last
year, subject: if, continuation and indentation, started May 27.)

John Y.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top