3 ms·
I recommend Zope's Restricted Python: https://pypi.python.org/pypi/RestrictedPython https://pypi.python.org/pypi/RestrictedPython for that sort of thing (this i
by Erwin 14y ago
I recommend Zope's Restricted Python: https://pypi.python.org/pypi/RestrictedPython https://pypi.python.org/pypi/RestrictedPython for that sort of thing (this is not like Python's now-dead restricted mode).
Restricted Python will recompile your code from something like "x.y(42)" into your_getattr(x, "y")(42). It will disallow access of any names starting with _, a number of other unsafe constructs etc.
So you can set up your sandbox as restricted as you want. For example the objects I expose have each an ACL so I can give users access to some system object's specific properties while disallowing modifications of them.