Is this the "right" way to do rexec?

John Roth newsgroups at jhrothjr.com
Wed Jun 30 07:29:12 EDT 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:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286134
>
> As written, it allows evaluation of either constants or more general
> expressions involving constants and operators (but not function
> calls).

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
Yahoo groups.

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.

John Roth





More information about the Python-list mailing list