Is there a native way of doing safe evaluation of simple Python expressions like those in:
a = ['None', 'False', '0', '0.0', '"s"', '(0,)', '[0,]']
These may for example be provided by HTTP GET like:
http://...?alfa=1&bravo=True&delta=1.0&charlie="s"&echo=None
The result of the evaluation should be Python types like None
, bool
, int
, float
, str
, etc.
Evaluation using Python eval
would be the obvious starting point, but since eval
is unsafe, it can't be used directly for evaluating arguments from HTTP GET.
What is a good way to do safe evaluation of simple Python expressions?