[Python-ideas] triple-quoted strings and indendation
Bruce Leban
bruce at leapyear.org
Thu May 12 00:57:32 CEST 2011
On Wed, May 11, 2011 at 3:40 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:
>
> Wild idea: make the unary + operator on strings do
> textwrap.dedent() on them.
>
>
Wouldn't the unary - operator make more sense since it's removing spaces?
But I would prefer that it use a slightly friendlier form of dedent:
def dedent_for_literal(s):
if s and s[0] == '\n':
s = s[1:]
if s and s[-1] == '\n':
s = s[:-1]
return textwrap.dedent(s)
That said, is this such a wart on the language that it's worth changing?
--- Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110511/0eaf1f97/attachment.html>
More information about the Python-ideas
mailing list