multiline strings and proper indentation/alignment

John Salerno johnjsal at NOSPAMgmail.com
Wed May 10 09:56:52 EDT 2006


bruno at modulix wrote:

> Why not trying by yourself ?-)

Doh! I always forget I can do this! :)


> Mmm. Not good. Let's try again:
>>>> print textwrap.dedent(s).strip()
> this is a multiline
> triple-quted string with
> indentation for nicer code formatting
> 
> Well, seems like we're done. About 2'30'' to solve the problem.

Actually, I'm still wondering if it's possible to remove the newlines at 
the end of the first and second lines (after 'multiline' and 'with'), so 
that the string is one line. But it's already been shown that textwrap 
alone doesn't do this, so I'd rather not mess with all the extra stuff 
to do it, when I can just put the string in parentheses.

Thanks.



More information about the Python-list mailing list