On Apr 27, 2014, at 12:34 PM, Chris Barker wrote:

>wow! just looked at that part of the PEP again, and that is a LOT of
>options. Is it impossible to come to any consensus on this? And as it
>happens, my favorite is not in there, though as far as I can tell not
>forbidden:
>
>foo = long_function_name(var_one,
>                                          var_two,
>                                          var_three,
>                                          var_four)

Wow, do you really indent those 42 columns?

This actually is forbidden because you're not using "vertical alignment" when
there is an argument on the first line.  You would have to line up `var_two`
right under `var_one` to be compliant.

>That is, I find that if the argument list is too long for one line, then
>splitting it out to only one argument per line is much more readable to me.

Sure.  The PEP outlines ways to do that.

>This becomes more important with default parameters:
>
>foo = long_function_name(var_one,
>                                          var_two=a_value,
>                                          var_three=some_other_value,
>                                          var_four=(a, tuple, of, values)
>                                          )
>as with more information in each argument, it's a lot more clear where one
>starts and the other begins. And it provides a nice place for comments:
>
>foo = long_function_name(var_one,
>                                          var_two=a_value, # because
>default doesn't frobnicate in this case
>                                          var_three=some_other_value,
>                                          var_four=(a, tuple, of, values)
>                                          )
>
>
>Anyway -- is there a point in trying to standardize this a bit more in
>PEP8, or has that battle long since been fought and conceded ?

The only thing I see wrong (from a PEP 8 standpoint) with your example, is
that your arguments are indented too far to the right.  But e.g. this would be
fine:

foo = long_function_name(var_one,
                         var_two=a_value,
                         var_three=some_other_value,
                         var_four=(a, tuple, of, values)
                         )

Cheers,
-Barry

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to