return same type of object

David Isaac aisaac0 at verizon.net
Tue Oct 24 10:28:23 EDT 2006


Instances of MyClass have a method that
returns another instance.  Ignoring the details
of why I might wish to do this, I could
return MyClass()
or
return self.__class__()

I like that latter better.  Should I?
Should I do something else altogether?

Thanks,
Alan Isaac





More information about the Python-list mailing list