Sometimes I rerun a script within the same ipython session and I get bad surprises when variables haven\'t been cleared. How do I clear all variables? And is it possible to
Adding the following lines to a new script will clear all variables each time you rerun the script:
from IPython import get_ipython get_ipython().magic('reset -sf')
To make life easy, you can add them to your default template.
In Spyder: Tools>Preferences>Editor>Edit template
Tools>Preferences>Editor>Edit template