Re: eval() woes

2006-08-29 Thread rdrink
Thanks everyone for you thoughtful replies... And yes Simon you are right... I do need to learn how to read 'tracebacks' (and de-bugging tools in general)... but you are the first person to give me a step-by-step explination, thank you. And LOL you all caught my dropped single-quote ;-) but

Re: eval() woes

2006-08-28 Thread Simon Forman
rdrink wrote: > Ok, maybe now I can make some more sense of this, with an example of > real code (sorry if it's a bit dense): > This is the basic function... > > def equate(parts,new_eq): > > oL = int(parts[0]) > iL = int(parts[1]) > iR = int(parts[2]) > oR = int(parts[3]) >

Re: eval() woes

2006-08-28 Thread Simon Forman
rdrink wrote: > Hey Simon, Thanks for the reply. > > Simon Forman wrote: > > You must be doing something weird, that equation works for me: > > Try posting the minimal code example that causes the error and the > > full, exact traceback that you get. > > I appreciate the offer... but at this point

Re: eval() woes

2006-08-28 Thread Gabriel Genellina
At Tuesday 29/8/2006 01:13, rdrink wrote: File "the_farmer2.py", line 112, in equate iL = int(parts[1]) ValueError: invalid literal for int(): - So parts[1] is '-'. Try adding a few print statements; I'd add a try/except around those lines, printing parts, I bet it's not what you expect

Re: eval() woes

2006-08-28 Thread John McMonagle
On Mon, 2006-08-28 at 21:13 -0700, rdrink wrote: > > (BTW, as a footnote: For each of the above 'equations' the function > equate() was called 500 times... in some cases with the list 'parts' > equaling things like ['0',2','3','0'], so I have no reason to believe > that the problem is with the wa

Re: eval() woes

2006-08-28 Thread rdrink
Ok, maybe now I can make some more sense of this, with an example of real code (sorry if it's a bit dense): This is the basic function... def equate(parts,new_eq): oL = int(parts[0]) iL = int(parts[1]) iR = int(parts[2]) oR = int(parts[3]) oLoL = int(str(o

Re: eval() woes

2006-08-28 Thread rdrink
Hey Simon, Thanks for the reply. Simon Forman wrote: > You must be doing something weird, that equation works for me: > Try posting the minimal code example that causes the error and the > full, exact traceback that you get. I appreciate the offer... but at this point my code is too recursive an

Re: eval() woes

2006-08-27 Thread Simon Forman
rdrink wrote: > n.n.h. (noob needs help) > Ok, I've been beating my head against this for a day... time to ask > others. > To explain things as simply as possible: > I am trying to use eval() to evaluate some simple equations, such as-- > pow(AB,2) > pow(AB,2)+A > pow(A+B,2) > pow(A+B,2)+A > and so

eval() woes

2006-08-27 Thread rdrink
n.n.h. (noob needs help) Ok, I've been beating my head against this for a day... time to ask others. To explain things as simply as possible: I am trying to use eval() to evaluate some simple equations, such as-- pow(AB,2) pow(AB,2)+A pow(A+B,2) pow(A+B,2)+A and so forth... for a variety of math o