I need an execution engine for simple user scripts in Python 3 (supposedly some limited subset of it). The thing is supposed to be used in educational game, so the user mainly want just run loops, test conditions and call a few of predefined functions (e.g. move()
and turn()
).
There are various posts and questions already (e.g. "sandboxing in Python") - they generally conclude that it is hard and existing approaches may have flaws (e.g. pysandbox
).
But I think I probably need something different - though I have no idea how to ask google properly. It may be something like limited python interpreter (supposedly also in python) which allows to intercept any function call and variable access and allow only whitelisted ones.
So please advice if there is anything of the kind.