How to enumerate an object’s properties in Python? [duplicate]

for property, value in vars(theObject).items():
    print(property, ":", value)

Be aware that in some rare cases there’s a __slots__ property, such classes often have no __dict__.

Leave a Comment