Metaclasses & docstrings in 2.2
Alex Martelli
aleax at aleax.it
Wed Jul 24 06:49:13 EDT 2002
Jeremy Bowers wrote:
> On Mon, 22 Jul 2002 23:00:59 -0500, I wrote:
>> class M1:
>> "M1's docstring."
>> def __init__(cls, name, bases, dict):
>> pass
>
> Ah. Moron source located.
>
> class M1(type):
> "M1's docstring."
> def __init__(cls, name, bases, dict):
> suprt(M1, cls).__init__(name, bases, dict)
>
> will work as I expected and do the right thing.
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.
This goes for metaclasses just as well as for
any other class, and for special methods just as
well as for non-special ones.
Alex
More information about the Python-list
mailing list