Print all properties of an Object in Python
class Animal(object): def __init__(self): self.eyes = 2 self.name = 'Dog' self.color= 'Spotted' self.legs= 4 self.age = 10 self.kids = 0 animal = Animal() animal.tail = 1 temp = vars(animal) for item in temp: print(item, ':', temp[item])
Sample output of above program.
kids : 0 eyes : 2 name : Dog color : Spotted tail : 1 legs : 4 age : 10
2019-07-12T00:06:46+05:30
2019-07-12T00:06:46+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution