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.

Author mark.dickinson
Recipients eric.smith, hawkowl, mark.dickinson, mbussonn
Date 2019-05-14.21:00:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557867629.8.0.559582462193.issue36911@roundup.psfhosted.org>
In-reply-to
Content
The AST _does_ correctly represent the Python string object in the source, though. After:

>>> s = """
... Hello \n world
... """

we have a Python object `s` of type `str`, which contains exactly three newlines, zero "n" characters, and zero backslashes. So:

>>> s == '\nHello \n world\n'
True


If the AST Str node value were '\nHello \\\n world\n' as you suggest, that would represent a different string to `s`: one containing two newline characters, one "n" and one backslash.

If you need to operate directly on the source as text, then the AST representation probably isn't what you want.
History
Date User Action Args
2019-05-14 21:00:29mark.dickinsonsetrecipients: + mark.dickinson, eric.smith, mbussonn, hawkowl
2019-05-14 21:00:29mark.dickinsonsetmessageid: <1557867629.8.0.559582462193.issue36911@roundup.psfhosted.org>
2019-05-14 21:00:29mark.dickinsonlinkissue36911 messages
2019-05-14 21:00:29mark.dickinsoncreate