No, this can't easily be done in current Python. I've had more
requests for totally independent Python interpreters along the lines
of Tcl, but in most cases what people really need was something much
simpler, e.g. separate modules or separate "globals" dictionaries for
code executed by exec, eval() or execfile(). The idea expressed here
looks quite elegant -- on the other hand "taintperl" seems to
implement a similar functionality without multiple interpreters.
It would not be very difficult to change Python to allow multiple
independent interpreter contexts, but it won't be trivial either --
there are some global variables here and there (especially the
current exception and the current execution frame) and some built-in
modules may not expect to be initialized more than once (these also
tend to use global variables -- e.g. sys).
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>