[Python-Dev] Re: Multiline string constants, include in the standard
library?
M.-A. Lemburg
mal@lemburg.com
Mon, 29 Jul 2002 11:02:43 +0200
Ville Vainio wrote:
> Which one looks better:
> ++++++++++++++++++++++++
> def usage():
> if 1:
> print """\
> You should have done this
> and that
> """.stripindent()
> +++++++++++++++++++++++++
> def usage():
> if 1:
> print """\
> You should have done this
> and that
> """
> ++++++++++++++++++++++++++
>
> When you are scanning code, the non-stripindent version of the 3-quoted
> string jumps at your face as a "top-level" construct, even if it is only
> associated with the usage() function.
I think everybody has their own way of formatting multi-line
strings and/or comments. There's no one-fits-all strategy.
So instead of trying to find a compromise, why don't you write up
a flexible helper function for the new textwrap module ?
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/