[Python-Dev] OT pet peeve (was: Re: str.dedent)
nico at tekNico.net
Sun Nov 13 10:05:58 CET 2005
> Sorry, I didn't mean to mislead. I wrote "easily" - I guess using the
> current textwrap.dedent isn't really hard, but still, writing:
> import textwrap
> r = some_func(textwrap.dedent('''\
> Seems harder to me than simply
> r = some_func('''\
> This example brings up another reason why "dedent" us a method is a
> good idea: It is a common convention to indent things according to the
> last opening bracket. "dedent" as a function makes the indentation
> grow in at least 7 characters, and in 16 characters if you don't do
> "from textwrap import dedent".
It's a common convention, but a rather ugly one. It makes harder breaking
lines at 78-80 chars, and using long enough identifiers.
I find it more useful to go straight to the next line, indenting the usual
four spaces (and also separating nested stuff):
r = some_func(
This style uses up more vertical space, but I find it also gives code a
clearer overall shape.
Nicola Larosa - nico at tekNico.net
Use of threads can be very deceptive. [...] in almost all cases they
also make debugging, testing, and maintenance vastly more difficult
and sometimes impossible.
More information about the Python-Dev