Parsing strings?

Michael Hudson mwh at python.net
Mon Apr 14 15:06:51 EDT 2003


Neil Schemenauer <nas-usenet at arctrix.com> writes:

> 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'

Oh yeah.

> > Don't think so -- and if there is, Lib/compiler/transformer.py would
> > like to know...
> 
> I guess someone should tell it.

Ah, now I remember the problem: PEP 263-style unicode issues.  I still
don't think there's a nice way of solving that one.

Cheers,
M.

-- 
  Screaming 14-year-old boys attempting to prove to each other that
  they are more 3133t than j00.
         -- Reason #8 for quitting slashdot today, from
            http://www.cs.washington.edu/homes/klee/misc/slashdot.html




More information about the Python-list mailing list