[Python-ideas] Multi-line strings that respect indentation

Ben Finney ben+python at benfinney.id.au
Sat Nov 6 02:13:32 CET 2010

"Carl M. Johnson"
<cmjohnson.mailinglist at gmail.com> writes:

> Can the parser be changed to do automagic joining on that the same way
> that it auto joins ("a"
> "b")?

There's no need to change the parser, when what you suggest works fine
in existing Python *and* is easier to maintain without the trailing

    def f(x):
        ("Am I a docstring\n"
         "even though I start in pieces?\n"
         "Oh, x is a dummy param\n")

But that's still crap. I think the existing situation works too: the
existing docstring processors already know to handle docstrings
according to <URL:http://www.python.org/dev/peps/pep-0257/#id20>.

Introducing more workarounds for multi-line strings, when the existing
tools appear to work fine, gets a -0.5 from me.

 \      “Fox News gives you both sides of every story: the President’s |
  `\  side and the Vice President’s side.” —Steven Colbert, 2006-04-29 |
_o__)                                                                  |
Ben Finney

More information about the Python-ideas mailing list