python get attributes of class

Solutions on MaxInterview for python get attributes of class by the best coders in the world

showing results for - "python get attributes of class"
Ron
05 Nov 2019
1for att in dir(your_object):
2    print (att, getattr(your_object,att))
Matilda
22 Apr 2019
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)