I often use the Python Console for running some lines of code and I also use some prints for checking the validity of the results.
If I run this sample code:
a = 2
b = 4
res = a + b
print res
it will print the value of the res
variable in the Python Console. However, if I then close the script tab, the res
variable is still there. This means that, if I type print res
in the Python Console, it will still return the last stored value.
I know that I can type:
del res
from the Python Console for deleting it. In fact, if I then type print res
, I get:
NameError: name 'res' is not defined
as expected, but this is useful only when dealing with one or two variables and if I remember the names of these variables.
After a few searches, I found these questions:
How to clear python console in QGIS?
Clearing Python Console in QGIS using Python Command
but their answers only explain how to clear the Python Console and not how to delete the variables.
Is there a programmatic way for deleting all the variables stored during the current QGIS session?