I am using pympler's muppy module to retrieve information about the memory.
What I would like to do is to be able to filter down the results by object type, like so:
objects = [o for o in objects if isinstance(o, Type)]
This works if in the code I specify the type, (e.g. Type=str) but I would also like to be able to ask users to write down the types they want to filter down. Except that when I do that, it will be stored as a string, which would give me the following:
isinstance(test, 'int')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a type or tuple of types
My question is, how can I get a string representing a type ('int', 'tuple', 'list', etc...) and transform it into a variable holding the type itself, so that I can use it as argument of the isinstance function.
Thank you for your help,