[Python-Dev] Return type of alternative constructors

Greg Ewing greg.ewing at canterbury.ac.nz
Sun May 8 20:55:09 EDT 2016
Guido van Rossum wrote:
> We could also consider this a general weakness of the "alternative 
> constructors are class methods" pattern. If instead these alternative 
> constructors were folded into the main constructor (e.g. via special 
> keyword args) it would be altogether clearer what a subclass should do.

A useful guideline might be that class methods can be provided
as sugar for alternative constructors, but they should all
funnel through the main constructor.

There's a convention like this in the Objective-C world where
one of an object's "init" methods is supposed to be documented
as the "designated initialiser", so that there is just one
thing that subclasses need to override.

-- 
Greg




More information about the Python-Dev mailing list