[IPython-user] Using IPShellEmbed

Fernando Perez fperez.net at gmail.com
Thu Oct 12 01:57:45 CDT 2006

On 10/11/06, Frédéric Mantegazza <mantegazza at ill.fr> wrote:

> Looking in the code, I found a 'user_ns' parameter in the IPShellEmbed
> __init__() method. I tried to use it to set my context, and it seems to
> work. The difference is that objects registered in that 'user_ns' context
> are not seen whith the 'who' command, but are available.
> What is exactly the purpose of this parameter? May I use it for what I want
> to do?

Yes, it allows you to set the user's local namespace.  The fact that
%who doesn't list its contents is an unfortunate implementation
artifact: when the shell starts, it first scans the contents of
user_ns and hides those keys from display with %who, so that anything
that got loaded before startup isn't shown, and you only see things
you actually created interactively.  That decision seemed like a good
policy when I wrote %who years ago (and ipshellembed didn't exist),
but it may not be such a good one in this context.  I'm not even 100%
sure it was such a good idea in the first place :)



More information about the IPython-user mailing list