title: How to replace an instance in __init__() with a different object?
body: <p>I am calling a constructor in ClassA and want to have the resulting object be of a different class (ClassB) if a certain condition is met.  I've tried replacing the first argument to __init__() ('self' in the example below) <em>within</em> __init__() but it doesn't seem to do what I want.</p>
  
  <p>in main:</p>
  
  <pre><code>import ClassA
  
  my_obj = ClassA.ClassA(500)
  # unfortunately, my_obj is a ClassA, but I want a ClassB!
  </code></pre>
  
  <p>in ClassA/__init__.py:</p>
  
  <pre><code>import ClassB
  
  class ClassA:
      def __init__(self,theirnumber):
          if(theirnumber &gt; 10):
              # all big numbers should be ClassB objects:
              self = ClassB.ClassB(theirnumber)
              return
          else:
              # numbers under 10 are ok in ClassA.
              return
  </code></pre>
  
  <p>in ClassB/__init__.py:</p>
  
  <pre><code>class ClassB:
      pass
  </code></pre>