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?
EDIT
Apologies, for a function, the PEP8 style guide actually says something like:
something = function_that_takes_long_arguments(
long_argument_1,
long_argument_2
)
pep8
python style guide checker doesn't think both snippets are acceptable.First option:
Second option (no warnings):
As you see, for the list it is okay to use both. But for the function, the second approach is preferred since in the first snippet the function body is indented as the previous line and it makes a negative impact on the readability.
I don't particularly care for this style, and I just checked, it's not in PEP 8, and it may interfere with any given IDE's ability to collapse code blocks (it does with the one I use at work for Python):
I'd rather you avoid it and do the following instead:
or
The list style is probably fine either way, though.
I'd usually use
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.