Returning an object based on __class__.__name__ in Python
<p>So I have a Superclass (which for simplicity I'll call), Mammal, from which classes Dog, Monkey, and Bear inherit methods.  Some of the inherited methods return an object that needs to be of the same class it is called from.  For example, <code>Dog.find(...)</code> should return Dog objects. But because the <code>find()</code> method is inherited from Mammal, the method can't be coded to explicitly <code>return Dog(...)</code>.  It would need to be able to return Dog, Monkey, Bear, or Mammal objects, depending on the value of <code>self.__class__.__name__</code>.</p>

<p>I've achieved this with <code>return eval(self.__class__.__name__)(...)</code>, but I'd prefer to avoid using eval. Is there a better way?</p>
