title: python - class fields as types
body: <p>In my code I need to make some classes A,B,C inherit from a class X.
  Classes A,B,C have their own exceptions (A_exception, B_exception, C_exception) which are raised from within their methods.</p>
  
  <pre><code>class A(X):
      def foo(self):
          raise A_exception('A_exception')
  
  class B(X):
      def foo(self):
          raise B_exception('B_exception')
  
  class C(X):
      def foo(self):
          raise C_exception('C_exception')
  </code></pre>
  
  <p>In the above example, how can I avoid to re-writing of the method foo()?
  Of course it's better if foo() is defined in class X with a generic exception type, but from A,B,C this generic type should be resolved into the specific type.
  Is it possible in Python to associate to a class, e.g. as a field, a specific class type? I've looked for it on internet but didn't find anything...</p>