title: How to run code when a class is subclassed?
body: <p>Is there a way to trigger code when my class is subclassed?</p>
  
  <pre><code>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")
  </code></pre>
  
  <p>Should output</p>
  
  <pre><code>foo
  was subclassed by SubClass0
  bar
  test
  was subclassed by SubClass1
  </code></pre>