[Python-ideas] Minor tweak to PEP 8?

Ben Finney ben+python at benfinney.id.au
Thu May 12 04:41:02 CEST 2011


Guido van Rossum <guido at python.org> writes:

> Yes:  # Aligned with opening delimiter
>        foo = long_function_name(var_one, var_two,
>                                var_three, var_four)

This is needlessly dependent on the content of the opening line; if that
changes, the rest need to change. It begs for the indentation to get
mis-aligned when other lines are edited.

>       # 4-space hanging indent; nothing on first line
>       foo = long_function_name(
>            var_one, var_two, var_three,
>           var_four)

This one doesn't have the previous problem, which is why it's what I
recommend.

I would be happy to see the latter explicitly recommended in PEP 8. If
the price of that is to have the former also recommended, I'd grumble
but it would be an improvement.

> No:   # Stuff on first line forbidden
>       foo = long_function_name(var_one, var_two,
>            var_three, var_four)
>
>       # 2-space hanging indent forbidden
>        foo = long_function_name(
>         var_one, var_two, var_three,
>          var_four)

I agree with pointing to both of these as bad examples.

-- 
 \      “People demand freedom of speech to make up for the freedom of |
  `\   thought which they avoid.” —Soren Aabye Kierkegaard (1813–1855) |
_o__)                                                                  |
Ben Finney




More information about the Python-ideas mailing list