A nice parsing library is pyparsing: http://pyparsing.wikispaces.com/ It contains a parser for mathematical expressions. There are examples in the source distribution. HTH, Eike.