Есть ли способ запуска кода, когда мой класс подклассифицирован?
class SuperClass:
def triggered_routine(subclass):
print("was subclassed by " + subclass.__name__)
magically_register_triggered_routine()
print("foo")
class SubClass0(SuperClass):
pass
print("bar")
class SubClass1(SuperClass):
print("test")
Должен выводить
foo
was subclassed by SubClass0
bar
test
was subclassed by SubClass1