Meaning of `\newline` as escape sequence

C

Chris Angelico

Hi all, in the documentation:

http://docs.python.org/3.3/reference/lexical_analysis.html

the escape sequence `\newline` is expained as "Backslash and newline
ignored". What does it mean?

It means this:
'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.

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top