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

Aahz aahz at pythoncraft.com
Wed May 20 14:10:08 CEST 2009


On Wed, May 20, 2009, Ben Finney wrote:
>
> 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))

That's almost what I do, except that I put the terminating container
character on its own line to simplify adding and deleting arguments::

    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)
            )

This practice comes more from lists/dicts; I simply generalize it to
arguments.  You'll also notice that similarly I put a trailing comma on
the last argument.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"A foolish consistency is the hobgoblin of little minds, adored by little
statesmen and philosophers and divines."  --Ralph Waldo Emerson



More information about the Python-ideas mailing list