replacement of rexec?

John J. Lee jjl at pobox.com
Wed Nov 5 10:39:36 EST 2003


"John Roth" <newsgroups at jhrothjr.com> writes:
> [Haiyu Zhu wrote:]
> > def safe_eval(s):
> >     """
> >     Evaluate strings that only contains the following structures:
> >     const,  tuple,  list,   dict
> >     """
> 
> This looks rather interesting. I frankly think we need it
> as a built-in.
[...]

Not a builtin, necessarily, but in the standard library would be nice.

I've written something like this before, only more ad-hoc, and wished
there was something like this available.


John




More information about the Python-list mailing list