python print class attributes code example
Example 1: python class get attribute by name
>>> class c:
pass
o = c()
>>> setattr(o, "foo", "bar")
>>> o.foo
'bar'
>>> getattr(o, "foo")
'bar'
Example 2: python print class variables
# to print out the variable names
print(vars(YourClass))
# to print out names and values
for var in vars(YourClass):
print(getattr(YourClass, var))