-
Indentation(缩进)
Continuation lines should align wrapped elements either vertically using Python's implicit line joining inside parentheses, brackets and braces, or using a hanging indent [7]. When using a hanging indent the following should be considered; there should be no arguments on the first line and further indentation should be used to clearly distinguish itself as a continuation line.
延续线应垂直对齐包裹元素,使用Python的隐含线连接括号,括号和括号内,或使用悬挂缩进[7]。 使用悬挂式凹痕时,应考虑以下因素; 第一行应该没有参数,应该使用进一步的缩进来明确区分自己作为延续线。
Yes
# Aligned with opening delimiter.
# 与开场分隔符对齐。
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Add 4 spaces (an extra level of indentation) to distinguish arguments from the rest.
# 添加4个空格(额外的缩进级别)以区分参数与其余参数。
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)
# Hanging indents should add a level.
# 悬挂的凹痕应该增加一个级别。
foo = long_function_name(
var_one, var_two,
var_three, var_four)
No
# Arguments on first line forbidden when not using vertical alignment.
# 不使用垂直对齐时禁止在第一行上的参数。
foo = long_function_name(var_one, var_two,
var_three, var_four)
# Further indentation required as indentation is not distinguishable.
# 由于压痕无法区分,因此需要进一步缩进。
def long_function_name(
var_one, var_two, var_three,
var_four):
print(var_one)