Is this the "right" way to do rexec?
newsgroups at jhrothjr.com
Wed Jun 30 13:29:12 CEST 2004
"Paul Miller" <pwmiller1 at adelphia.net> wrote in message
news:2e363c08.0406291833.28e62e2d at posting.google.com...
> I came across this recipe on the Python Cookbook site:
> As written, it allows evaluation of either constants or more general
> expressions involving constants and operators (but not function
I wouldn't do it that way, as evidenced by the fact that I didn't
do it that way. I took the approach of running the compiler
tools to generate an AST, and then interpreting the result.
You can see the code (including the reference to
wherever I picked up the notion) in the TypeAdapter module
of PyFIT (version 0.5a1 and higher) which you can find in
the files section of either the extremeprogramming or FitNesse
Of course, that approach is useful where each execution
is a one time thing. If you need to generate something and
use it many times, then verifying the byte code may be the
way to go.
More information about the Python-list