RFC PEP candidate: q'<delim>'quoted<delim> ?

Bengt Richter bokr at oz.net
Mon Mar 11 04:58:38 CET 2002


On Mon, 11 Mar 2002 16:31:45 +1300, Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:

>Bengt Richter wrote:
>> 
>> Would someone explain this:
>> 
>>  >>> eval("list(r'\x07')")
>>  ['\x07']
>>  >>> list(r'\x07')
>>  ['\\', 'x', '0', '7']
>
>The string literal you're passing to eval is
>non-raw, so the \x07 gets interpreted before
>eval even sees it. Try this instead:
>
>   >>> eval(r"list(r'\x07')")
>
Aaugh, touché & d'oh. That's embarrassing  ;-/

Regards,
Bengt Richter





More information about the Python-list mailing list