Feature request: create a 'clear' to erase the variables #10688

Open
crazyBaboon opened this Issue Jul 2, 2017 · 2 comments

Comments

Projects
None yet
3 participants

crazyBaboon commented Jul 2, 2017 edited

It would be very nice to have a command called clear or clear_all to clear the variables from the workspace from a script file. This already exists in Matlab, Octave, Scilab. In Ipython, this can be achieved by:

from IPython import get_ipython
get_ipython().magic('reset -sf')

which is quite inelegant, cumbersome and not intuitive at all. Could these calls not be replaced by a single clear function? the name could be similar

Owner

takluyver commented Jul 3, 2017

When you %run a script, we create a clean namespace for it, and then copy the variables it creates across into your interactive namespace after it finishes. So you're automatically getting major benefit of clearing the namespace at the start of a script.

From a Jupyter interface, restarting the kernel is the recommended way to get to a clean slate.

I don't think we need easier ways for a script to directly clear your interactive namespace.

Owner

Carreau commented Jul 4, 2017

if you are running a .ipy script, %reset -sf also works. You do not ned to use the expanded form.

takluyver added this to the no action milestone Jul 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment