How do I convert arithemtic string (like "2+2") to a number?

Michael Hartl mhartl at post.harvard.edu
Sun Feb 6 02:29:30 EST 2005


Adam brings up a good point: eval is a very general function which
evaluates an arbitrary Python expression.  As a result, it (and its
close cousin exec) should be used with caution if security is an issue.

Michael




More information about the Python-list mailing list