1

在以下情况下,我应该如何改进许多或长变量的分配以遵循规则 E122 和 E501:

def my_example_function():
    return 1, 2, 3, 4
# How can I improve the following line:
first_variable, second_variable, third_variable, fourth_variable = my_example_function()
4

2 回答 2

3

只需将它跨越多行..

( first_variable, second_variable, 
  third_variable, fourth_variable ) = my_example_function()
于 2015-11-09T17:14:23.130 回答
1

E122 表示该行应少于 80 个字符,E501 表示续行应缩进。 重写该行的一种常见方法是,

first_variable, second_variable, third_variable, fourth_variable = \   
    my_example_function()
于 2015-11-09T17:27:32.367 回答