[Python-Dev] [Python-checkins] peps: Add rules for indenting continuation lines.

Lennart Regebro regebro at gmail.com
Fri Jun 3 12:09:34 CEST 2011


On Fri, Jun 3, 2011 at 00:15, Barry Warsaw <barry at python.org> wrote:
> On Jun 02, 2011, at 12:57 PM, Glenn Linderman wrote:
>
>>On 6/2/2011 12:01 PM, Guido van Rossum wrote:
>>> Bingo. That's why. (Though you are missing some colons in your examples.:-)
>>>
>>> --Guido
>>
>>You operate as a good Python compiler :)
>
> Actually, this is a key insight, which I just mentioned in a private response
> to Steve.  How about this for the rule:
>
> If the hanging line ends in a colon, then double-indent (or "more-ly
> indented") seems appropriate.  If not, then a single indent is sufficient.
>
> That handles cases like this, where double indent makes sense:
>
> def some_really_long_function_name(
>        an_argument,
>        another_argument,
>        and_a_third_argument):
>    foo()
>
> ---
>
>    if some_really_long_function_name(
>            an_argument,
>            another_argument,
>            and_a_third_argument):
>        foo()
>
> ---
>
> and these cases where a single indent is fine:
>
>    x = some_really_long_function_name(
>        an_argument,
>        another_argument,
>        and_a_third_argument)
>    foo(x)
>
> ---
>
>    d = dict(
>        a=1,
>        b=2,
>        c=3,
>        d=4)
>    return d
>
> Does that cover it?

I like it.


More information about the Python-Dev mailing list