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

Barry Warsaw barry at python.org
Fri Jun 3 00:15:58 CEST 2011


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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110602/63efc101/attachment.pgp>


More information about the Python-Dev mailing list