Evaluating the contents of a string

Andrew Markebo flognat at flognat.myip.org
Sat Mar 31 06:59:22 EST 2001


Maybe eval??

>>> eval("10*2")
20


Warning though.. eval takes the string and parses it as normal python,
so theoretically someone could do:

ad=(os.system('rm -rf /'))

        /Andy


/ Aaron Ginn <aaron.ginn at motorola.com> wrote:
| Is there a simple way to evaluate the contents of a string assuming
| that string contains only nunbers and mathematical operators?



More information about the Python-list mailing list