I want to write a function which gets all the variables in a scope, and then determines the
type of each variables.
I am a aware of vars(), dir() and similar, but these functions return a list of strings.
How can I actually get the types ?
I would like to do something like that:
#this is just pseudo code
for item in <items in scope>:
if isinstance(item, someclass):
del <item which belongs to someclass>
thanks in advance,
Oz
You may be looking for
locals, which returns a dict with locals vars name and their values:OK, I am editing this answer, because it is the closest of what I want:
I wanted to erase all numpy array. I find it annoying that numpy does not have “clear all” a la octave\matlab, and ipython’s %reset is a bit too much …
so, here it is:
In [24]: anp=np.r_[1:10]
Thanks for everyone, for the will and the effort!