Late binding eval()?

Jeremy Bowers jerf at jerf.org
Tue Aug 24 16:11:26 EDT 2004


On Tue, 24 Aug 2004 18:25:54 +0000, Kevin Smith wrote:

> However, in my application, I'm getting an arbitrary expression 
> from the user.

How arbitrary? Using the various parsing packages, it is easy to set up a
math calculator with any features you want, for instance, if you just mean
"arbitrary math".

If you're worried about security, this is really the only safe way to do
it. If you aren't worried about security... then I don't know enough about
what you are doing to have any other suggestions, but I would point out in
the general case even the Python interpeter can't guess in advance what
variables will be used, thanks to the magic of "getattr" and friends.



More information about the Python-list mailing list