Python parse for mathematical expressions