This will prevent the import of both python modules and .Net objects, possibly not the way you want. (I'm relatively new to Python, so I might as well skip some things):
Environment setting. Import everything you need for the user to have access. Either add to their script, or do:
__builtins__.__import__ = None #Stops imports working reload = None #Stops reloading working (specifically stops them reloading builtins #giving back an unbroken __import___!
then execute their script.
source share