Meaning of `\newline` as escape sequence
rosuav at gmail.com
Fri Dec 28 16:50:37 CET 2012
On Sat, Dec 29, 2012 at 2:42 AM, Marco <name.surname at gmail.com> wrote:
> Hi all, in the documentation:
> the escape sequence `\newline` is expained as "Backslash and newline
> ignored". What does it mean?
It means this:
>>> foo = "This is\
'This is one string.'
Note that the leading space isn't an indent - it's just part of the
quoted string. There's no newline in the resulting string, unlike what
happens with a triple-quoted string. The backslash and line break are
both ignored, meaning that the string is exactly the same as if they
hadn't been there.
But be careful with this sort of thing - a single trailing space on
the line with the backslash will break the string syntactically. The
backslash has to be the absolute last character on the line.
More information about the Python-list