Bruno wrote:
> This is usually known as a 'factory method'. You do realise that both
solutions are *not* strictky equilavent, do you?

Your point I believe is that after inheritance the factory method
in the subclass will still
return MyClass()
but will return an instance of the subclass if I
return self.__class__()

Right.

You did not comment further so I take it your view is that
each is fine, pick the one that gives the behavior you want.
But Steve suggests going with the latter.
Here is an (very crude) argument for going with the latter:
if you know you want an instance of MyClass(),
you can do that directly, but if you do this via a factory method,
then  (after inheritance) the action of the factory method becomes obscured.

Does that make any sense?

Thanks,
Alan Isaac
of the factory


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to