OK. I know the experts have spoken and you should not ever use python\'s eval()
on untrusted data, ever. I\'m not smarter than the rest of the world, and s
Zope has a thing called RestrictedPython, you may want to check it, at least to validate your approach or possibly reuse their code. It is configurable and re-usable.
Here's my other answer to a similar question.
Try asteval, seems like the thing you need. Otherwise there is this safe eval