Getting attributes of a python class

The inspect module provides several useful functions to help get information about live objects such as modules, classes, methods, functions, tracebacks, frame objects, and code objects. The getmembers(object) method return all the members of an object in a list of (name, value) pairs sorted by name. example
import inspect class ClassAttrTest(object): myVar_1 = '100' myVar_2 = '200' def myfunc(self): return self.myVar_1 print(inspect.getmembers(ClassAttrTest, lambda myVar_1:not(inspect.isroutine(myVar_1))))
output
[('__class__', < class 'type' > ), ('__dict__', mappingproxy({'__weakref__': < attri bute '__weakref__' of 'ClassAttrTest' objects > , '__module__': '__main__', '__doc __': None, 'myfunc': < function ClassAttrTest.myfunc at 0x0000000002E26F28 > , '__d ict__': < attribute '__dict__' of 'ClassAttrTest' objects > , 'myVar_1': '100', 'my Var_2': '200'})), ('__doc__', None), ('__module__', '__main__'), ('__weakref__', < attribute '__weakref__' of 'ClassAttrTest' objects > ), ('myVar_1', '100'), ('my Var_2', '200')]