Proposal: default __init__
Andrew Dalke
dalke at acm.org
Tue Nov 14 02:01:44 EST 2000
Aahz Maruch wrote:
>while
>Python does not have any restrictions on argument types passed to
>methods (and functions), Python does definitely restrict the number of
>items in the parameter list for a method (modulo specific mechanisms for
>creating variable-length parameter lists). Following the "explicit is
>better than implicit" rule, you are therefore required to create the
>signature of any method/function that you wish to call.
*Except* that
class Blah:
pass
blah = Blah()
works without having an explicit Blah.__init__. This violates the
"explicit is better than implicit" rule in favor of making it easier
to create classes.
Suppose that all classes needed to define an __init__ in order to
create an instance. Then the signature would be explicit in all cases
and I could always call BaseClass.__init__(self, ...) and I would
not be suggesting this proposal.
Classes don't need an __init__ to create instances, and that's the
crux of the problem.
Andrew
dalke at acm.org
More information about the Python-list
mailing list