[Python-ideas] Fwd: Minor tweak to PEP 8?
Guido van Rossum
guido at python.org
Sat Jun 4 18:52:03 CEST 2011
[Correct list address]
Yeah, please prepare a patch. Maybe you can send it to Barry so he can
check it in. I would use 4-space indent for the "Opt:" exanple at the
end though.
On Sat, Jun 4, 2011 at 9:03 AM, Steven Klass <sklass at pointcircle.com> wrote:
> Hey Barry,
> You are correct - it was an artifact from the email tool..
> Guido - it appears we are reaching some consensus. Thoughts? Did you want me
> to update the repo?
> Continuation lines should align wrapped elements either vertically
> using
> Python's implicit line joining inside parentheses, brackets and braces,
> or
> or using a hanging indent. When using a hanging indent the following
> considerations should be applied; there should be no arguments on the
> first line and further indentation should be used to clearly distinguish
> the itself as a continuation line.
>
> Yes: # Aligned with opening delimiter
> foo = long_function_name(var_one, var_two,
> var_three, var_four)
> # More indentation included to distiguish this from the rest.
> def long_function_name(
> var_one, var_two, var_three,
> var_four):
> print(var_one)
> No: # Stuff on first line forbidden when not using vertical alignment
> foo = long_function_name(var_one, var_two,
> var_three, var_four)
> # Further indentation required as indentation is not
> distiguishable
> def long_function_name(
> var_one, var_two, var_three,
> var_four):
> print(var_one)
>
> Opt: # Extra indentation not necessary.
> foo = long_function_name(
> var_one, var_two,
> var_three, var_four)
>
>
>
> On Fri, Jun 3, 2011 at 11:09 AM, Barry Warsaw <barry at python.org> wrote:
>>
>> Hi Steven,
>>
>> On Jun 03, 2011, at 08:57 AM, Steven Klass wrote:
>>
>> > Continuation lines should align wrapped elements either vertically
>> > using
>> > Python's implicit line joining inside parentheses, brackets and
>> > braces,
>> > or or using a hanging indent. When using a hanging indent the
>> > following
>> > considerations should be applied; there should be no arguments on the
>> > first line and further indentation should be used to clearly
>> > distinguish
>> > the itself as a continuation line.
>> >
>> > Yes: # Aligned with opening delimiter
>> > foo = long_function_name(var_one, var_two,
>> > var_three, var_four)
>> -------------------------------------^
>> I'm sure that's just an email alignment bug, right?
>>
>> >
>> > # More indentation included to distiguish this from the rest.
>> > def long_function_name(
>> > var_one, var_two, var_three,
>> > var_four):
>> > print(var_one)
>> >
>> >
>> > No: # Stuff on first line forbidden when not using vertical
>> > alignment
>> > foo = long_function_name(var_one, var_two,
>> > var_three, var_four)
>> >
>> > # Further indentation required as indentation is not
>> > distiguishable
>> > def long_function_name(
>> > var_one, var_two, var_three,
>> > var_four):
>> > print(var_one)
>> >
>> >
>> >Thoughts?
>>
>> That looks great to me, thanks. I would add one more example to the 'Yes'
>> section to cover the case we've been talking about:
>>
>> # Extra indentation not necessary.
>> foo = long_function_name(
>> var_one, var_two,
>> var_three, var_four)
>>
>> This doesn't say that extra indentation isn't allowed, just that it's not
>> necessary, so I think it strikes the right balance.
>>
>> Cheers,
>> -Barry
>
>
>
> --
> ---
>
> Steven M. Klass
>
> ☎ 1 (480) 225-1112
> ✉ sklass at pointcircle.com
>
--
--Guido van Rossum (python.org/~guido)
More information about the Python-ideas
mailing list