Best way to evaluate boolean expressions from strings?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Apr 27 13:24:04 EDT 2009
En Mon, 27 Apr 2009 14:03:01 -0300, Gustavo Narea <me at gustavonarea.net>
escribió:
> I need to evaluate boolean expressions like "foo == 1" or "foo ==1 and
> (bar > 2 or bar == 0)" which are defined as strings (in a database or
> a plain text file, for example). How would you achieve this?
This recent thread may be of interest:
Safe eval of moderately simple math expressions
http://groups.google.com/group/comp.lang.python/t/c1aff28494ab5b59/
--
Gabriel Genellina
More information about the Python-list
mailing list