for att in dir(your_object):
print (att, getattr(your_object,att))
import inspect
class myclass:
a = 5
def method(b):
return b
for i in inspect.getmembers(myclass):
print(i)
getattr(object, 'attribute_name')
>>> class new_class():
... def __init__(self, number):
... self.multi = int(number) * 2
... self.str = str(number)
...
>>> a = new_class(2)
>>> a.__dict__
{'multi': 4, 'str': '2'}
>>> a.__dict__.keys()
dict_keys(['multi', 'str'])
field_name = "fullName"
print getattr(user, field_name) # prints content of user.fullName
Use the built-in function dir()