class Car:
def __init__(self, name):
self.name = name
def sound(self):
return "Vroooom!"
ferrari = Car("ferrari")
print(ferrari.sound())
# define class
class example:
# define __call__ function
def __call__(self):
print("It worked!")
# create instance
g = example()
# when attempting to call instance of class it will call the __class method
g()
# prints It worked!