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

spir denis.spir at free.fr
Wed May 20 10:20:52 CEST 2009


Le Wed, 20 May 2009 11:38:55 +0900,
"Stephen J. Turnbull" <stephen at xemacs.org> s'exprima ainsi:

>  >             yield Message(parseTime(attr(u'received')), who, text(msg),
>  > isAction)  
> 
> Mildly hard to read; I tend to skip the details of a complex call on
> one line, and have to go back if I need them.  Eg, in review I would
> very like miss a typo where the 2nd and 3rd arguments are
> (incorrectly) swapped unless I read that line token by token.  I'm much
> less likely to make that mistake for
> 
>             yield Message(parseTime(attr(u'received')), who,
>                           text(msg), isAction)
> 
> although I grant that at 81 characters for the long line, the two-line
> format is distinctly uglier.

One wall I run into with lines < 80 characters is, paradoxally, that I miss width for lines I want to break (!).

The issue is that,
~ in order to have logical, comprehensible, layout,
~ and to avoid messing up with python's own indent
the continuation lines have to align with items on the same logical level in the first line, for instance:

            try:
                my_final_result = finalResultProducer(arg1_from_abunch_of_args,
                                                      args_should_align_properly,
                                                      [so, what, if, they, re, compound])
            except AttributeError, error:
                raise ResultError( "foo .........         bar"
                                   "<--All message text lines should start here."
                                   %(String, interpolation, argument, list, as, well) )

Note that I started the try...except at a rather low level (3).

Denis
------
la vita e estrany



More information about the Python-ideas mailing list