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

Gerald Britton gerald.britton at gmail.com
Wed May 20 17:17:14 CEST 2009


Also, it's convenient to remember that you can wrap any expression in
parentheses which can help in situations like this:

raise (


         ValueError


         ), (

             "what were you thinking?"

         )

Using this approach, you can indent (or not) however you like.  It's a
convenient way to break up long lines and you can get improved
readability as a side-effect.

On Wed, May 20, 2009 at 9:44 AM, George Sakkis <george.sakkis at gmail.com> wrote:
> 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
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
Gerald Britton



More information about the Python-ideas mailing list