Add rules for indenting continuation lines.

This commit is contained in:
Guido van Rossum 2011-06-02 11:09:20 -07:00
parent 0abda1e625
commit 848640dd6b
1 changed files with 23 additions and 0 deletions

View File

@ -57,6 +57,29 @@ Code lay-out
For really old code that you don't want to mess up, you can continue to
use 8-space tabs.
Continuation lines should align wrapped elements either vertically using
Python's implicit line joining inside parentheses, brackets and braces,
or using a hanging indent of double your code indention, in which case
there should be no argument on the first line. For example:
Yes: # Aligned with opening delimiter
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Double code indention for hanging indent; nothing on first line
foo = long_function_name(
var_one, var_two, var_three,
var_four)
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)
Tabs or Spaces?
Never mix tabs and spaces.