# to print out the variable names
print(vars(YourClass))
# to print out names and values
for var in vars(YourClass):
print(getattr(YourClass, var))
class yourClass:
def __str__(self):
return "value" #replace value with what you want to print
an = Animal()
attrs = vars(an)
# {'kids': 0, 'name': 'Dog', 'color': 'Spotted', 'age': 10, 'legs': 2, 'smell': 'Alot'}
# now dump this in some way or another
print(', '.join("%s: %s" % item for item in attrs.items()))