Name rebinding

Joshua Macy amused at webamused.com
Thu Mar 16 18:46:19 EST 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