<p dir="ltr">The semantics of raw strings are clear. I don't see that they should be called out especially in any context. (Except for regexps.) Usually exec() is not used with a literal anyway (what would be the point).</p>

<p dir="ltr">--Guido van Rossum (sent from Android phone)</p>
<div class="gmail_quote">On Jun 15, 2013 1:03 PM, "Ron Adam" <<a href="mailto:ron3200@gmail.com">ron3200@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
On 06/14/2013 04:03 PM, PJ Eby wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>Should this be the same?<br>
><br>
><br>
>python3 -c 'print(bytes("""\r\n""", "utf8"))'<br>
>b'\r\n'<br>
><br>
><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

>>>>eval('print(bytes("""\r\n"<u></u>"", "utf8"))')<br>
</blockquote></blockquote></blockquote>
>b'\n'<br>
</blockquote>
No, but:<br>
<br>
eval(r'print(bytes("""\r\n""", "utf8"))')<br>
<br>
should be.  (And is.)<br>
<br>
What I believe you and Walter are missing is that the \r\n in the eval<br>
strings are converted early if you don't make the enclosing string<br>
raw.  So what you're eval-ing is not what you think you are eval-ing,<br>
hence the confusion.<br>
</blockquote>
<br>
Yes thanks, seems like an easy mistake to make.<br>
<br>
To be clear...<br>
<br>
The string to eval is parsed when the eval line is tokenized in the scope containing the eval() function.  The eval function then parses the resulting string object it receives as it's input.<br>
<br>
There is no mention of using raw strings in the docs on evel and exec.  I think there should be, because the intention (in most cases) is for eval to parse the string, and not for it to be parsed or changed before it's evaluated by eval or exec.<br>

<br>
An example using a string with escape characters might make it clearer.<br>
<br>
Cheers,<br>
   Ron<br>
______________________________<u></u>_________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-dev" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="http://mail.python.org/mailman/options/python-dev/guido%40python.org" target="_blank">http://mail.python.org/<u></u>mailman/options/python-dev/<u></u>guido%40python.org</a><br>
</blockquote></div>