Parsing strings (\n and \\)

Fredrik Lundh fredrik at pythonware.com
Tue Jun 25 12:01:21 EDT 2002


François Pinard wrote:

> 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, {}, {})

>>> UNPARSED = "__import__('os').system('echo dream on!')"
>>> PARSED = eval(UNPARSED, {}, {})
dream on!

</F>





More information about the Python-list mailing list