[Python-ideas] 80 character line width vs. something wider

George Sakkis george.sakkis at gmail.com
Wed May 20 15:44:46 CEST 2009


On Wed, May 20, 2009 at 5:40 AM, Ben Finney <ben+python at benfinney.id.au> wrote:

> spir <denis.spir at free.fr> writes:
>
>>             try:
>>                 my_final_result = finalResultComputer(arg1_from_abunch_of_args,
>>                                                       args_should_align_properly,
>>                                                       [so, what, if, they, re, compound])
>>             except AttributeError, error:
>>                 raise computeError( "foo .........         bar"
>>                                     "<--All message text lines should start here."
>>                                     %(String, interpolation, argument, list, as, well) )
>
> It's for this reason that I advocate indenting continued lines *one*
> level, and not this hideously large increase in indentation for a single
> step.
>
> Simply break at the opening container character, and indent a single
> level to make all the contents line up::
>
>    try:
>        my_final_result = finalResultComputer(
>            arg1_from_abunch_of_args,
>            args_should_align_properly,
>            [so, what, if, they, re, compound])
>    except AttributeError, error:
>        raise computeError(
>            "foo .........         bar"
>            "<--All message text lines should start here."
>            % (String, interpolation, argument, list, as, well))

I do this sometimes, but only if not every argument fits between the
opening parenthesis and the 80-char limit. Otherwise, I typically
indent them at the "(" level, i.e.:

    try:
        my_final_result = finalResultComputer(somelongname,
                                                                otherlongname,

[some, subexpression])
    except AttributeError, error:
        raise computeError("foo .........         bar",
                                     "<--some message" % (interpolation, args))

George



More information about the Python-ideas mailing list