Indentation of closing parenthesis

coding-style, pep8, python

Solution

I'd usually use

some_kind_of_list = [
    1, 2, 3,
    4, 5, 6,
]

def function_that_takes_long_arguments(
    long_argument_1,
    long_argument_2,
):
    return long_argument_1

This way indentation will be distinguishable. Also having a comma at the end of the last argument makes it possible to add new args later without changing other lines which is usually a good thing for git-blaming purposes and makes less clutter in diffs.

Problem

Note: Don't believe anything in the original question is correct, go to the bottom for an update. Original question I believe the PEP8 style guide says that both ``` some_kind_of_list = [ 1, 2, 3, 4, 5, 6 ] def function_that_takes_long_arguments( long_argument_1, long_argument_2 ): return long_argument_1 ``` and ``` some_kind_of_list = [ 1, 2, 3, 4, 5, 6 ] def function_that_takes_long_arguments( long_argument_1, long_argument_2 ): return long_argument_1 ``` are acceptable, but does it make sense to use one or the other, e.g., if I move onto C++ later on in my life? Update To set the record straight, the common style for function definitions is: ``` def function_that_takes_long_arguments( long_argument_1, long_argument_2): pass # Note the extra indentation in the 2 lines above # or def function_that_takes_long_arguments(long_argument_1, long_argument_2): pass ``` whereas for function calls it's: ``` function_that_takes_long_arguments( long_argument_1, long_argument_2 ) # or function_that_takes_long_arguments( long_argument_1, long_argument_2) # or function_that_takes_long_arguments(long_argument_1, long_argument_2) ```

Original source

Related problems