How Would You Do: Parsing and Expression Evaluation

Al Christians achrist at easystreet.com
Tue Apr 27 01:20:17 EDT 2004


I've got an idea for an application, and I wonder how much of what it 
takes to create it is available in open source python components.

My plan is this -- I want to do a simple spreadsheet-like application:
I've used a wxGrid, so I expect that wxPython will do fine for the user 
interface.   The spreadsheet can be organized vertically, one item per 
line.  It might need no more than 100 rows or so.  On each line, the 
user will enter in one column an item (variable) name and, in another 
column, a formula or  expression for computing the item's value.  A 
third column will show the computed value.   There will usually be some 
circular references between the items, but their values will converge 
quickly with repeated evaluation.

The final feature is a button that the user can click when they have the
sheet set up correctly -- it will translate the formulas into simple C 
and python code to perform the same calculations as the spreadsheet.

The formulas should be pretty easy -- add, subtract, multiply, divide,
log, exponential,  and perhaps some user-defined functions.

Are there any off-the-shelf python libraries that would make this kind 
of app much easier?  I don't have any special experience related to such 
things, so I surely don't want to re-invent the wheel out of pure 
ignorance -- should I try the parsing tools in the standard python 
library, or will something else work better for me?

TIA for any advice,


Al



More information about the Python-list mailing list