[Python-Dev] eval and triple quoted strings
Guido van Rossum
guido at python.org
Mon Jun 17 19:22:01 CEST 2013
On Mon, Jun 17, 2013 at 10:04 AM, Walter Dörwald <walter at livinglogic.de> wrote:
> I expected that eval()ing a string that contains the characters
>
> U+0027: APOSTROPHE
> U+0027: APOSTROPHE
> U+0027: APOSTROPHE
> U+000D: CR
> U+000A: LR
> U+0027: APOSTROPHE
> U+0027: APOSTROPHE
> U+0027: APOSTROPHE
>
> to return a string containing the characters:
>
> U+000D: CR
> U+000A: LR
No. Executing a file containing those exact characters produces a
string containing only '\n' and exec/eval is meant to behave the same
way. The string may not have originated from a file, so the universal
newlines behavior of the io module is irrelevant here -- the parser
must implement its own equivalent processing, and it does.
--
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev
mailing list