1import inspect
2
3class myclass:
4 a = 5
5 def method(b):
6 return b
7
8for i in inspect.getmembers(myclass):
9 print(i)
1>>> class new_class():
2... def __init__(self, number):
3... self.multi = int(number) * 2
4... self.str = str(number)
5...
6>>> a = new_class(2)
7>>> a.__dict__
8{'multi': 4, 'str': '2'}
9>>> a.__dict__.keys()
10dict_keys(['multi', 'str'])
11
1field_name = "fullName"
2print getattr(user, field_name) # prints content of user.fullName
3