I'm working on a calculator in python. Introductory college course, so I know some stuff, but I'm far from being an expert of any sorts.

This is a scientific/graphing calculator, so I'm parsing a whole string of input.

Say the user inputs integ(3*x+3,0,1) (integrate 3x+3 from 0 to 1). My integration function wants parameters f, a, and b. How do I make eval call integ(), passing the variable x, without trying to see x as a variable? Considering this is a calculator, I'm expecting the possibility of long convoluted input crap such as diff(integ(3*x+3,0,1)*x+5,5)*(3*5)/4 (diff being the differentiate function)

I've ready plenty about calling functions and such with eval. Basically my question is, how do I call a function with eval() and pass it variable parameters?

Code snippets follow.

```
evalvars = {}
evalvars['integ'] = integ
def integ(funct,a,b):
def f(x):
return map(lambda x: eval(funct),x)
return gauss(a,b,f) #function I wrote for gaussian quadrature integration
def evaluate():
equation = entry.get() #raw input from entry box
answer = eval(equation, evalvars)
```

When I run this with raw input 'integ(3*x+5,0,1)' I get NameError: name 'x' is not defined

Alternatively, if you have any helpful hints for parsing user input into function calls, it would be very helpful. This is turning out to be the hardest part of this little graphing calculator I'm making. (what a surprise)

*Edited 6 Years Ago by iamdabobo*: n/a