D'Arcy J.M. Cain wrote:
On Mon, 7 Sep 2009 15:29:23 +1000
"jwither" <jwit...@sxder4kmju.com> wrote:
Given a string (read from a file) which contains raw escape sequences, (specifically, slash n), what is the best way to convert that to a parsed string, where the escape sequence has been replaced (specifically, by a NEWLINE token)?

I don't know what your actual requirement is but maybe this fits:

exec("print '%s'" % x)

Lots of fun when preceded by:
    x = "'; sys.exit(); print 'b"

or far nastier things.  Exec is the same level of dangerous as eval.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to