eval() woes

rdrink rdrink at gmail.com
Mon Aug 28 22:19:08 EDT 2006


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
and deeply nested to send a "simple" example

> (Also, assuming your equations are already strings, there's no reason
> to call str() on them again.

This is an interesting point: I AM putting them into the file as
strings, and then pulling them back out as such and you are right, they
do not need to be re-cast as strings. I think as some point I was
getting errors there, but for now I can omit that....

> And you mention a "dictionary level" but
> don't mention using a dict.)

Sorry, that was a spurious thought... No I'm not using a dict (although
I am still not sure if I should be)...

> FWIW, the error "ValueError: invalid literal for int()" occurs when
> you, uh, pass an invalid literal to the int() function (actually int
> type.. but not important here), and includes the invalid input so you
> don't have to guess at it:
>
> |>> int('wombat')
> HTH

Yes that is helpful.
I am still getting errors... which leads me to belive that it all has
to do with how I am casting, and re-casting, things as strings and
ints.
I need a little more time to try to suss this all out; after which, if
I still can't get it to work, I'll post some more code.

Thanks again for your thoughts and comments.

Robb




More information about the Python-list mailing list