Skip to content

PEP-8: clarify if multiline argument list with a closing ) on a separate line is acceptable #1267

Closed
@allan-simon

Description

@allan-simon

https://www.python.org/dev/peps/pep-0008/#indentation states

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.

and then gives two examples

in yes it gives :

foo = long_function_name(
    var_one, var_two,
    var_three, var_four)

(with 1 indentation)

and in no it gives

# Further indentation required as indentation is not distinguishable.
def long_function_name(
    var_one, var_two, var_three,
    var_four):
    print(var_one)

my question:

is

def long_function_name(
    var_one, var_two, var_three,
    var_four
):  # <----   it visually make clear that print is not inside the argument list , so it is now distinguishable
    print(var_one)

"possible" ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions