multiline strings and proper indentation/alignment
Dave Hansen
iddw at hotmail.com
Wed May 10 10:57:42 EDT 2006
On Wed, 10 May 2006 13:56:52 GMT in comp.lang.python, John Salerno
<johnjsal at NOSPAMgmail.com> wrote:
>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
Well, it's too long for my news reader to display the result on a
single line, but:
>>> print textwrap.dedent(s).strip().replace('\n',' ')
this is a multiline triple-quted string with indentation for nicer
code formatting
>>>
>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.
If that's the way you want the sting in the first place, that'd be my
recommendation. Regards,
-=Dave
--
Change is inevitable, progress is not.
More information about the Python-list
mailing list