class Example(): def __init__(self): self.x = 100 self.y = 200 e = Example() print(e.__dict__)class Fruit: def __init__(self, apple = 5, banana = 10): self.apple = apple self.banana = banana eat = Fruit() # returns __dict__ of the eat object print(vars(eat))# function vars() is defined as: vars([object]) -> dictionary # the vars() function takes an object and returns a its __dict__ attribute, # which is a dictionary of all of its writable attributes class Person: def __init__(self, name = "anonymous", age = 21, employed = True): self.name = name self.age = age Sam = Person() John = Person('John', 18) # notice the 'employed' attribute is not returned print(vars(Sam)) # {'name': "anonymous", 'age': 21} print(vars(John)) # {'name': "John", 'age': 18}class Example(): def __init__(self): self.x = 100 self.y = 200 e = Example() print(e.__dict__)