spyder - clear variable explorer along with variables from memory
Go to the IPython console in the Spyder IDE and type %reset. It will prompt you to enter (y/n) as the variables once deleted cannot be retrieved. Type 'y' and hit enter. That's it.
In Spyder, Do following steps
Run
Configuration per file...
Clear all variables before execution [Select Checkbox]
This actually clears variables from previous run of the file. Hope it helps.
Surfing on the web, I found a hack to solve the annoying problem of clearing the variable explorer every time you want to execute again a script:
def clear_all():
"""Clears all the variables from the workspace of the spyder application."""
gl = globals().copy()
for var in gl:
if var[0] == '_': continue
if 'func' in str(globals()[var]): continue
if 'module' in str(globals()[var]): continue
del globals()[var]
if __name__ == "__main__":
clear_all()
# insert here your code
Basically, it consists of executing the function clear_all()
just before everything else. It is writing by yourself the same Matlab's function.
Here the link to the git issue where the solution was proposed.