initializing mutable class attributes

Dan Perl dperl at rogers.com
Wed Sep 1 12:24:32 EDT 2004


I'm not sure what you mean by removing the object as ancestor, but here is a
modified code similar to Jorge's and it doesn't work:
    class test:
        pass

    class derived(test):
        def __init__(self):
                test.__init__(self)

    d = derived()

The call to test.__init__(self) raises an AttributeError exception.

Dan

"Diez B. Roggisch" <deetsNOSPAM at web.de> wrote in message
news:ch4skh$223$04$1 at news.t-online.com...
> Dan Perl wrote:
>
> > My mistake.  You're right, and it's all because of the inheritance from
> > 'object', which probably defines a default, empty, __init__.  I haven't
> > made a habit of subclassing from 'object' yet and I see that I'll have
to
> > do
> > that.  Thanks.
>
> You can safely remove the object as ancestor - it works with old-style
> classes, too.
>
> -- 
> Regards,
>
> Diez B. Roggisch





More information about the Python-list mailing list