title: How to return a subclass from __new__ parameter
body: <p>I have a class parent and two subclasses child1(parent) and child2(parent) sort of like the following near code.
  (edited to more properly show that the parent class is doing something)</p>
  
  <pre><code>class parent(object):
    name = None
  
    def __init__(self,e):
      # process the common attributes
      name = e.attrib['name']
  
    def __new__(cls,e):
      if e.attrib['type'] == 'c1':
        return child1(e)
      elif e.attrib['type'] == 'c2':
        return child2(e)
      else:
        raise 
  
  class child1(parent):
    extra1 = None
    def __init__(self,e):
      super(e)
      # set attributes from e that are specific to type c1
  
  class child2(parent):
    extra2 = None
    def __init__(self,e):
      super(e)
      # set attributes from e that are specific to type c2
  </code></pre>
  
  <p>The goal is to be able to  get the "right" class based on the value of the parameter.  So if I can say <code>obj = parent(element)</code> and <code>obj</code> will be either <code>child1</code> or <code>child2</code> depending on what the value of <code>element.attrib['type']</code> is.</p>