Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
allan-simon opened this issue Jan 2, 2020 · 4 comments

Comments

@allan-simon
Copy link

allan-simon commented Jan 2, 2020

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" ?

@allan-simon
Copy link
Author

allan-simon commented Jan 2, 2020

especially if you see this other example

    # Add a comment, which will provide some distinction in editors
    # supporting syntax highlighting.
    if (this_is_one_thing and
        that_is_another_thing):
        # Since both conditions are true, we can frobnicate.
        do_something()

where a comment is given as possible way to have only 1 indentation

so at the very least the docstring should play the same role and allows :

def long_function_name(
    var_one, var_two, var_three,
    var_four
): 
    """The doc string is also a comment """ 
    print(var_one)

@Rosuav
Copy link
Contributor

Rosuav commented Jan 2, 2020

This repository is administrative and isn't the best place to discuss whether something should or shouldn't be recommended. I advise taking your question to python-list.

@hugovk
Copy link
Member

hugovk commented Jan 2, 2020

Discourse may be a good place too:

@allan-simon
Copy link
Author

@hugovk thanks for the pointer, I will post there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants