Mark Dickinson <dicki...@gmail.com> added the comment:

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.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36911>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to