Extending classes __init__behavior for newbies

rantingrick rantingrick at gmail.com
Sun Feb 13 17:25:07 EST 2011


On Feb 13, 4:00 pm, James Mills <prolo... at shortcircuit.net.au> wrote:

[snip]

> When you subclass a base class (ship in your example) you need
> to call it's parent (or super) methods. This includes the constructor
> (__init__).
>
> The standard way of doing this in Python is:
>
> class FasterShip(Ship):
>
>     def __init__(self, l=0,b=0,t=0,name='', speed=0):
>         super(FasterShip, self).__init__(l, b, t, name)


Is super really necessary here James? I think the use of super in this
manner is just as confusing to noobs as using map/filter are to list
comprehensions/generators. However in exactly the opposite
"syntactical" way since dumping super reduces syntax. Not trying to
pick on you, just curious.




More information about the Python-list mailing list