Add command 'clear' to spyder - Feature request
See original GitHub issueDescription of your problem
So far, the only script command to clear the workspace variables is the horrible command:
from IPython import get_ipython
get_ipython().magic('reset -sf')
I am aware of this, but it really does not address this problem as the “option to “clear all” variables before running file” is still GUI defined and once enabled, it will always clear all the variables for every re-run until the user disables it again. Typically only the scripts that start with ‘clear all’ are intended to clear the workspace, the other scripts that don’t start with ‘clear all’ are not. Whether the workspace is cleared or not should be defined in the script and not in the GUI preferences.
‘clear all’ and ‘clear’ are extremely useful Matlab, GNU Octave, FreeMat and Scilab functions that are not yet implemented in Spyder.
A possible solution would be to create a spyder or Ipython function called clear all the would basically call the horrible aforementioned command. What do you guys think?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)

Top Related StackOverflow Question
Sorry, but if we add a command like that then things won’t work outside of Spyder.
I have tested the command
from IPython import get_ipython get_ipython().magic('reset -sf')and it does not work, i.e. it does not clear the workspace. In addition it makes the variable explorer stop displaying variables. Is this my machine being weird? I am using spyder 3.1.4 and python 3.6.1, Antergos Linux 64 bit