Extending classes __init__behavior for newbies

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Feb 13 17:42:31 EST 2011


On Feb 13, 2011 5:37 PM, "James Mills" <prologic at shortcircuit.net.au> wrote:
>
> On Mon, Feb 14, 2011 at 8:21 AM, MRAB <python at mrabarnett.plus.com> wrote:
> > I would've done it this way:
> >
> > class FasterShip(Ship):
> >    def __init__(self, speed=0, **kwargs):
> >        Ship.__init__(self, **kwargs)
> >        self.speed = speed
>
> What's the difference between calling the base
> class's constructor directly and using the super type ?
>
> cheers
> James
>
> --

In this case, nothing. If you use multiple inheritance  and you end up with
weird inheritance heirarchies, super might not return the class you think it
will return.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110213/74ff0ccc/attachment.html>


More information about the Python-list mailing list