calculating a string equation
Astan Chee
astan.chee at al.com.au
Thu Feb 11 16:43:25 EST 2010
Hi,
I have some variables in my script that looks like this:
vars = {'var_a':'10','var_b':'4'}
eqat = "(var_a/2.0) <= var_b"
result = "(var_a+var_b)/7"
What I'm trying to do is to plug in var_a and var_b's values from vars
into eqat and see if eqat returns true or false as well as getting the
value of result if these variables were "plugged in". How do I do this?
I'm also expecting eqat and result to contain various python
mathematical operators like **, and compounded ()'s.
I'm not sure how to convert the equation; if I have to make a bunch of
if-statements or if there is a python function that already does
something like this.
Thanks for any help.
Cheers
Astan
More information about the Python-list
mailing list