[Tutor] Inheritance : what am I doing wrong?
alan.gauld@bt.com
alan.gauld@bt.com
Sat Nov 30 12:57:48 2002
> I'm having a problem with inheritance.
I don't think so :-)
> class ball(visual.sphere):
> def __init__(self):
> visual.sphere.__init__(self, radius = 0.5)
You shouldn't be able to do that.
You must set radius outside the call to the function.
radius = 0.5
visual.sphere.__init__(self, radius)
> self.velocity = visual.vector(0, 0, 0)
> And I get the following error message:
> TypeError: __init__() takes exactly 2 arguments (4 given)
This seems to match the visual vector call - have you checked
the parameters of that constructor?
I don't think its anything to do with inheritance per se but
just how you are calling the functions.
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld