Parsing strings?

Neil Schemenauer nas-usenet at arctrix.com
Mon Apr 14 17:15:32 CEST 2003


Michael Hudson <mwh at python.net> wrote:
> tweedgeezer at hotmail.com (Jeremy Fincher) writes:
> 
>> Is there any way to turn a string (in Python format, escapes and all)
>> into an actual Python string without using eval()?
>> 
>> I.e., I'd like to turn the four-character string "\\x00" into the
>> one-character Python string "\x00" without using eval().  Is there any
>> way to do that?

In Python 2.3 courtesy of MvL:

    >>> '\\x00'.decode('string-escape')
    '\x00'

> Don't think so -- and if there is, Lib/compiler/transformer.py would
> like to know...

I guess someone should tell it.

  Neil




More information about the Python-list mailing list