Parsing strings (\n and \\)
François Pinard
pinard at iro.umontreal.ca
Tue Jun 25 11:07:03 EDT 2002
[Thomas Guettler]
> Is there a function for parsing c-like
> strings? I need to parse strings containing
> '\n' and '\\' '\"'.
A simple avenue is to get Python itself to evaluate the string as a constant
(you ensure this by removing evaluation context). Something like this:
PARSED = eval(UNPARSED, {}, {})
But this is a bit rough, there are cases you want more precise control
over the string syntax.
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list