This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: New Line escape issue in raw strings
Type: behavior Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ardath.kevin, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-09-28 20:39 by ardath.kevin, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg377624 - (view) Author: Kevin Ardath (ardath.kevin) Date: 2020-09-28 20:39
When attempting to concatenate some strings with a new line, I observed that formatting braces in a raw string skipped a new line escape:

print(r'{{}}\nx'.format())

Produces:
{}\nx

Rather than:
{}
x
msg377640 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-09-28 22:25
It is expected behavior. \n in a raw string means two characters, backslash and "n", not a single newline character. Use non-raw string to embed a newline character.
History
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86047
2020-09-29 02:16:16ardath.kevinsetstatus: open -> closed
resolution: not a bug
stage: resolved
2020-09-28 22:25:15serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg377640
2020-09-28 20:39:53ardath.kevincreate