On 29/05/23 8:10 am, James Schaffler wrote:
However, some minimal testing of InteractiveInterpreter leads me to believe that the Interpreter object has its own view of local/global variables and therefore shouldn't be able to affect the calling interpreter
Globals you create by executing code in the REPL have their own namespace. But everything else is shared -- builtins, imported Python modules, imported C extension modules, etc. etc. There's a long-running project to make it possible to have multiple fully-isolated Python interpreters in one process, but the way CPython is structured makes that very difficult to achieve, and as far as I know it's not there yet. In the case of IDLE, there's really no reason not to use a subprocess[1]. It's easy and guarantees 100% isolation. [1] Well, mostly. There used to be a small hitch on Windows with the default firewall settings not letting you connect to a local socket (nice one, Microsoft). I don't know whether that's still an issue. -- Greg -- https://mail.python.org/mailman/listinfo/python-list