👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
Is there a way to trigger code when my class is subclassed?
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
👻 Read also: what is the best laptop for engineering students?