wasm-demo/demo/ermis-f/python_m/cur/0931

29 lines
692 B
Plaintext

From: fredrik at pythonware.com (Fredrik Lundh)
Date: Tue, 13 Apr 1999 07:26:50 GMT
Subject: Converting a string to a tuple
References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov>
Message-ID: <00f501be857f$ff636f40$f29b12c2@pythonware.com>
X-UID: 931
Charles G Waldman wrote:
> If you're concerned about safety (the "eval" could be evaluating any
> Python code, possibly a hazard if the string is coming from user
> input) then you don't want to use eval at all.
try:
result = eval(string, {"__builtins__": {}})
or:
import rexec
r = rexec.RExec()
result = r.r_eval(string)
</F>