Executing other python code

Stefan Behnel stefan.behnel-n05pAM at web.de
Tue Jan 29 15:46:06 CET 2008


Tim Rau wrote:
> I'm working on a game, and I'd like players to be able to define thier
> ships with scripts. Naturally, I don't want to give them the entire
> program as thier romping ground. I would like to invoke a seperate
> interpreter for these files, and give it a limited subset of the
> functions in my game. What is the best way to achieve this effect?

Depends. If you are concerned about security, this will be hard to achieve in
Python. I imagine that this could be related to cheating prevention.

If you are more concerned about namespace polution and making only a well
defined API available to the scripts, go the module-import way and hand some
API object over, either through an initialisation function or by injecting it
into the module namespace, as Arnaud suggested.


More information about the Python-list mailing list