Forward declaration of class in Python
<p>I have some classes looking like this:</p>

<pre><code>class Base:
  subs = [Sub3,Sub1]
  # Note that this is NOT a list of all subclasses!
  # Order is also important

class Sub1(Base): pass
class Sub2(Base): pass
class Sub3(Base): pass
...
</code></pre>

<p>Now, this fails because Sub1 and Sub3 are not defined when Base.subs is. But obviously I can't put the subclasses before Base either. Is there a way to forward-declare classes in Python? I want to work with <code>isinstance</code> so the types in subs actually have to be the same as the later declared subclasses, it's not enough that they have the same name and other properties.</p>

<p>One workaround is to do: <code>Base.subs = [Sub3,Sub1]</code> <em>after</em> the subclasses have been defined, but I don't like having to split my class in that way.</p>

<p>edit: Added information about order</p>
