simple string question
Scott David Daniels
Scott.Daniels at Acm.Org
Tue Sep 8 16:26:13 EDT 2009
D'Arcy J.M. Cain wrote:
> On Mon, 7 Sep 2009 15:29:23 +1000
> "jwither" <jwither at 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.Daniels at Acm.Org
More information about the Python-list
mailing list