On 11/5/10 7:48 PM, Carl M. Johnson wrote:
On Fri, Nov 5, 2010 at 10:37 AM, Terry Reedytjreedy@udel.edu wrote:
On 11/5/2010 10:45 AM, Nick Coghlan wrote:
I do use the textwrap.dedent workaround myself, but I think it is sufficiently flawed for a proper fix to be worth considering:
- It doesn't work for docstrings (as Tal pointed out)
This does:
def f(x): "Am I a docstring\n"\ "even though I start in pieces?\n"\ "Oh, x is a dummy param\n" pass print(f.__doc__)
# prints 3 lines, but not without '' escape at line ends
Can the parser be changed to do automagic joining on that the same way that it auto joins ("a"
"b")? I can't imagine any scenario where anyone would rely on starting the line after a docstring with a string literal, since the only plausible run time effect it might have would be to intern some strings for later. Even "string".method() wouldn't have any effect without something like x = in front of.
def f(x):
... ("Am I a docstring\n" ... "even though I start in pieces?\n" ... "Oh, x is a dummy param\n") ... pass ...
print(f.__doc__)
Am I a docstring even though I start in pieces? Oh, x is a dummy param