Name rebinding

Joshua Macy amused at webamused.com
Fri Mar 17 00:46:19 CET 2000


ccg at mudprovider.com wrote:
> 
>  I'm trying to set up an in-game scripting language using python - but the
> game itself is also in python.  Is there any way I can prevent the scripts
> from being able to rebind non-script variables/functions/methods/classes
> while still allowing them access to at least a sub-set of the non-script
> code?  Here's a simple example of what I'm talking about:
> 
>  class GameInterface:
>         # Whatever...
> 
>  def someGameFunction(script, gameInterface):
>         # ...
>         script.execute(gameInterface)
>         # ...
> 
>  class Script:
>         def execute(self, interface):
>                 # I want this to work:
>                 interface.someFunction()
> 
>                 # But not this
>                 class Badness:
>                         # Evil malicious code
> 
>                 global GameInterface
>                 GameInterface = Badness
> 
>  Thanks in advance


  Take a look at the rexec and Bastion modules.

Joshua



More information about the Python-list mailing list