Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Meaning of `\newline` as escape sequence (http://www.velocityreviews.com/forums/t955901-meaning-of-newline-as-escape-sequence.html)

Marco 12-28-2012 03:42 PM

Meaning of `\newline` as escape sequence
 
Hi all, in the documentation:

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

the escape sequence `\newline` is expained as "Backslash and newline
ignored". What does it mean?
Thanks in advance, M.
--
Marco

Chris Angelico 12-28-2012 03:50 PM

Re: Meaning of `\newline` as escape sequence
 
On Sat, Dec 29, 2012 at 2:42 AM, Marco <name.surname@gmail.com> wrote:
> Hi all, in the documentation:
>
> http://docs.python.org/3.3/reference..._analysis.html
>
> the escape sequence `\newline` is expained as "Backslash and newline
> ignored". What does it mean?


It means this:

>>> foo = "This is\

one string."
>>> foo

'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


All times are GMT. The time now is 08:55 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.