safeeval.py: Safe eval replacement with whitelist support
- class SafeEvaluator(safedict=None, defaultSafe=True)
This class provides a safe eval replacement.
The method eval() will only evaluate the expressions considered safe (whitelisted). By default it has a whitelist of mathematical expressions that can be turn off using defaultSafe=False at init
The user can add more safe functions passing a safedict to the addSafe() or init methods.
Functions can be removed by name using removeSafe()
Note: In order to use variables defined outside, the user must explicitly declare them safe.