[IPython-User] Magic reset except user namespace given to start_ipython

Thomas Kluyver takowl@gmail....
Tue Sep 10 13:23:22 CDT 2013


On 10 September 2013 11:08, Hugo Gagnon <opensource.ipython@user.fastmail.fm
> wrote:

> Once in ipython, is it possible to reset my namespace (using the %reset
> magic) except for whatever is contained in "my_ns"?
>
> If not, what would be the best way to go about it?
>

If you can get those items 'hidden', then I think '%reset -s' (soft reset)
should skip over them. Passing in user_ns might achieve that automatically,
otherwise you'd have to create a shell object and use shell.push({...},
hidden=True).

If neither that nor the duster extension Lev mentions (which is new to me)
do what you want, it should be easy to write your own magic to do this:
call self.shell.reset(), then put whatever you want back in shell.user_ns.
You can use '%reset??' to see the implementation of the %reset magic.

Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130910/f87ed1c2/attachment.html 


More information about the IPython-User mailing list