Message342519
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. |
|
Date |
User |
Action |
Args |
2019-05-14 21:00:29 | mark.dickinson | set | recipients:
+ mark.dickinson, eric.smith, mbussonn, hawkowl |
2019-05-14 21:00:29 | mark.dickinson | set | messageid: <1557867629.8.0.559582462193.issue36911@roundup.psfhosted.org> |
2019-05-14 21:00:29 | mark.dickinson | link | issue36911 messages |
2019-05-14 21:00:29 | mark.dickinson | create | |
|