Hot to split string literals that will across two or more lines ?
iddw at hotmail.com
Tue Nov 22 21:22:11 CET 2005
On Tue, 22 Nov 2005 18:38:15 +0000 in comp.lang.python, Steve Holden
<steve at holdenweb.com> wrote:
>Of course there's also the alternative of escaping the newlines out in
>the literal. The replace result above is exactly
>lots of text hundreds of characters long\
>more text on another line but we really don't want any line breaks\
>in our final string\
>so we replace newlines in this multiline string\
>with an empty string thus\
That's pretty close, but\
if you don't include spaces at the ends of words\
then Python will run those words\
together, which is probably not what you want."""
"That's pretty close, butif you don't include spaces at the ends of
wordsthen Python will run those wordstogether, which is probably not
what you want."
So you need to add spaces, but make sure they're \
before the backslash, and not after."""
"So you need to add spaces, but make sure they're before the
backslash, and not after."
Change is inevitable, progress is not.
More information about the Python-list