To clear the console we can use the following command -
import subprocess as sp
tmp = sp.call('cls',shell=True)
However, to remove a variable from memory, we often rely upon -
del
command But both of them are variable specific and hence time-consuming. So is there any general command (like clear
under MATLAB) to remove a variable from memory and thereafter from Spyder's Variable Explorer.
To trigger a refresh, simply click the reload button on the Variable Explorer toolbar, or press the shortcut Ctrl+R ( Cmd-R ) when it has focus.
python clear all variables To clear Variables in Python just use %reset-f. You can clear variables in python by using %reset-f function. If you want to delete any specific variable then use %reset-f.
CTRL + L does clear the terminal screen but it does not clear variables--you need a kernel restart for that.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With