I am trying to understand how to use mixins in python. I want to make Bird, Dog and Bat class to have the eat
method from PetMixIn
class but also can be self instance. How should I do it?
class Pet(object):
def __init__(self, food):
self.food = food
def eat(self):
print(f'Eatting...{self.food}')
class PetMixIn(object):
def eat(self):
print('Eatting...')
class Animal(object):
def __init__(self, life):
self.liferange = life
class Bird(Animal):
def __init__(self, life, flyable):
super.__init__(lift)
self.flyable = flyable
#bird attribution ...
class Dog(Animal):
def __init__(self, life, name):
super.__init__(lift)
self.name = name
#dog attribution ...
class Bat(Animal):
def __init__(self, life, size):
super.__init__(lift)
self.size = size
#bat attribution ...
bat = Bat(40, '1')
dog = Dog(10, 'tom')
bird = Bird(3, True)