##// END OF EJS Templates
Merge pull request #648 from takluyver/usermod...
Merge pull request #648 from takluyver/usermod Clean up handling of global namespaces with the proper semantics. A global namespace should always be tied to a module: pickle accesses classes via the module in which they're defined. So I've changed the arguments for instantiating an InteractiveShell to include `user_module` in place of `user_global_ns`. The global namespace simply becomes a reference to `user_module.__dict__`. For instantiating InteractiveShell, there are four possibilities: * Neither `user_ns` nor `user_module` is given. A new (real) module is created named `__main__`, and its `__dict__` becomes the global and local namespace. This is what happens when starting IPython normally. * Only `user_module` is given. Its `__dict__` becomes the global and local namespace. * Both `user_ns` and `user_module` are given. `user_module.__dict__` is the global namespace, and `user_ns` is the local namespace. Note that we can't interactively define closures over variables in the local namespace (this seems to be a limitation of Python). * Only `user_ns` is given. It is treated as the global and local namespace, and a `DummyMod` object is created to refer to it. This is intended as a convenience, especially for the test suite. The recommended way to pass in a single global namespace is as a reference to the module. `embed()` digs out the locals and the module from the frame in which it's called. Closes gh-29, closes gh-693.
Fernando Perez -
r5467:a1e4911b merge
Show More