On Tuesday, May 30th, 2023 at 9:14 PM, Greg Ewing wrote: > 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.
Thanks for the explanation. Could you elaborate on precisely how "everything else is shared"? As far as I understand, if you run the following code: from code import InteractiveInterpreter interp = InteractiveInterpreter() import numpy as np interp.runcode("np.__name__") this will result in the error Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'np' is not defined which seems to imply that imports in the parent shell are not shared with interpreters and vice versa (if you swap the places of the import and the __name__ call). Thanks, Jim -- https://mail.python.org/mailman/listinfo/python-list