Extending classes __init__behavior for newbies

Benjamin J. Racine bjracine at glosten.com
Sun Feb 13 16:17:55 EST 2011


I don't quite understand the interplay of the two different __init__ methods when trying to extend a class.  Below is my hack attempt at doing so...

class ship(object):
    def __init__(self,l=0,b=0,t=0,name=''):
        self.l = l
        self.b = b
        self.t = t
        self.name<http://self.name> = name
    def make_it_deeper(self,t):
        self.t = self.t - t

class fast_ship(ship):
    def __init__(self,speed = 0):
        self.speed = speed

my_ship = fast_ship(l = 100,b = 50, t = 10, name = 'cutter',speed = 10)


If anyone would be so kind as to show me how to get the intended effect that I've hinted at, I would be most grateful,

Ben

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110213/c1231cda/attachment.html>


More information about the Python-list mailing list