
# --------------------------------------------------
# Миксин для преобразования к строке

class ToStringMixin:
    def __str__(self):
        return f"{self.__class__.__name__}({str(self.__dict__)})"

class MyClass(ToStringMixin):
    def __init__(self, x, y):
        self.x = x
        self.y = y
def main():
    obj = MyClass(1, 2)
    print(obj)

if __name__ == '__main__':
    main()


# --------------------------------------------------
# Миксин для подстчета количества экземпляров

class CountInstancesMixin:
    count = 0

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.__class__.count += 1

class Cat(CountInstancesMixin):
    def __init__(self, name):
        self.name = name
        super().__init__()

class Dog(CountInstancesMixin):
    def __init__(self, name):
        super().__init__()


def main():
    o1 = Cat('qwe')
    o2 = Cat('ewer')

    o3 = Dog('sdf')

    print(Cat.count)
    print(Dog.count)



if __name__ == '__main__':
    main()