当调用带有长参数列表的函数时,右括号是否应该放在单独的行上?例如:
import module1.module2
def main():
# alternative 1, closing parenthesis on separate line
x=3
y=4
my_result_name_1, my_result_name_2 = module1.module2.function3(
argument_name1, argument_name2, keyword_argument=(x,y)
)
print(my_result_name_1)
# alternative 2, closing parenthesis on same line as last argument
x=3
y=4
my_result_name_1, my_result_name_2 = module1.module2.function3(
argument_name1, argument_name2, keyword_argument=(x,y))
print(my_result_name_1)
return
if __name__ == '__main__':
main()
PEP8中的例子让我有点困惑。首先,他们有这样一个例子:
^{pr2}$后来,他们有了这个:
my_list = [
1, 2, 3,
4, 5, 6,
]
喜欢哪种款式?在
就个人而言,当我只需要第二行时,我把左括号和右括号放在一行,例如:
但是如果我要多写一行,我会把内容放在单独的行上,例如:
^{pr2}$真的要由你决定你想怎么做。对我来说,最重要的是可读性和一致性。在
相关问题 更多 >
编程相关推荐