Reputation: 31
I'm trying to write myself a program that calculates a function taken from a Tk.Entry().
The problem is, when I try to run my display() function
(it runs Tkinter, sets up the window, and calls root.Mainloop()),
I get parse errors coming from eval() from a function that is supposed to be called only if the user inputs all of the variables and presses a button (the button's command).
The function uses eval(variable), while variable is entry.get().
What am I doing wrong here?
def cfunc(_n,_f,_t0,_tn,):
xbase=[]
tbase=[]
t=0
n2=eval(_n) #Stuff happens here, cfunc gets entry_n.get() as arguments.
f2=_f #Also, tabs are correct in the original.
tmin2=eval(_t0)
tmax2=eval(_tn)
tr=tmax2-tmin2
sk = tr / n2
i2=tmin2
Also, error:
File "Q:\Py\counter.py", line 89, in
cfunc n2=eval(_n) File "", line 0
^ SyntaxError: unexpected EOF while parsing
Upvotes: 1
Views: 409
Reputation: 385980
You haven't shown us the code that causes the error (the value of _n) so we can only guess. A couple words of advice:
the error message is telling you the problem: unexpected eof. That means there's a missing closing quote or brace or something like that. The parser got to the end of the "file" (the string being eval'd) before it got the characters it expected.
put a print statement immediately before an eval, and use some special characters to delimit it (eg: puts ">>>$_n<<<") so you can tell precisely what is in the string being eval'd, including any leading or trailing spaces.
Upvotes: 1