For the following example, is there a way to get the type of a and b as int and string?
class test(object):
def __init__(self):
self.a = 1
self.b = "abc"
test_obj = test()
for var in vars(test_obj):
print type(var) # this just returns string type as expected (see explanation below)
type(var).__name__vars(test_obj)is a dictionary and sovaris just the variable names'a'and'b'.print(type(getattr(test_obj, var)))