[Tutor] Implementing a MUD engine from scratch

Kent Johnson kent37 at tds.net
Thu Dec 14 02:32:15 CET 2006

Christer Enfors wrote:
> Now on to my actual questions:
> 1) I want to be able to update parts of the code (the game content) 
> while the MUD (the engine) is running. Errors in the game shouldn't stop 
> the entire MUD - I guess I should use exceptions for this? Any pointers 
> as to where I should begin to research how to accomplish this? I'm 
> guessing that perhaps IDLE could be worth a look (since it is a Python 
> program that allows you to edit and run Python programs inside it).
> 2) Would it be realistically possible to sandbox my MUD, so that 
> arbitrary Python programs (written by appointed MUD staff) can't affect 
> the hosting machine?

Unfortunately these are both problematic.

You can reload a module with the reload() function but this will not fix 
up references to the contents of the module. In particular if you define 
classes in the module, instances of the classes will refer to the old 
definition even if you reload the module with a new definition.

There are some recipes in the online cookbook to work around this, 
search for 'reload':

Python does not provide a secure sandboxed environment and there is no 
clear way to do that. This is a matter of frequent discussion on 
comp.lang.python, searching there for sandbox may be educational:

Sorry, I don't have time or energy to dig up more details at the moment.


More information about the Tutor mailing list