1class yourClass:
2 def __str__(self):
3 return "value" #replace value with what you want to print
1>>> class Test:
2... def __repr__(self):
3... return "Test()"
4... def __str__(self):
5... return "member of Test"
6...
7>>> t = Test()
8>>> t
9Test()
10>>> print(t)
11member of Test
1# to print out the variable names
2print(vars(YourClass))
3
4# to print out names and values
5for var in vars(YourClass):
6 print(getattr(YourClass, var))