Metaclasses & docstrings in 2.2

James Kew james.kew at btinternet.com
Wed Jul 24 07:35:06 EDT 2002


"Alex Martelli" <aleax at aleax.it> wrote in message
news:JCv%8.110249$Jj7.2629802 at news1.tin.it...
>
> When your __init__ (or any other method) *just*
> delegates to the superclass, and nothing else,
> simply remove that method's definition from
> your class -- inherit it rather than going to
> the trouble of overriding just to delegate,
> which buys you nothing.

I was wondering about this recently: I can see that leaving it out is more
efficient, but leaving it in does make the class slightly easier to use:

a) clients of the class don't have to wander up the class hierarchy to
discover what the __init__ parameters are, and

b) writers of subclasses of the class which add their own __init__ don't
have to wander up the class hierarchy to discover which superclass to call
__init__ on and what parameters to pass.

I suspect the proper Pythonic answer to both is "document, don't code"?

James






More information about the Python-list mailing list