How to process user supplied formulas?
<p>I have a dictionary containing a set of key values available through a web application:
I want to process user supplied formulas like:
((value1+value3)/value4)*100</p>

<p>What would be the easiest way to get the formula calculated matching values with ones from the dictionary?</p>

<p>Consider this example:</p>

<pre><code>#!/usr/bin/python
values={'value1':10,'value2':1245,'value3':674365,'value4':65432,'value5':131}
formula=raw_input('Please enter formula:')
</code></pre>

<p>If I supply the formula '((value1+value3)/value4)*100' how can I map the value1 etc to map value1 from the dictionary and calculate the result?</p>

<p>Cheers,</p>
