[Tutor] [Q] inheriting a class

alan.gauld@bt.com alan.gauld@bt.com
Tue, 22 Jan 2002 00:12:43 -0000


> I wanted to add a new method to the existing class and I 
> thought it would be possible with the following code.
> 
> ####
> class ball( sphere ):
>     def printProperty():  #<--- Close but you need self 
>         print 'print property'

> I wanted to use the parent class's __init__ method, 

> I tried typed
> the above codes in the pythons shell, 

What codes? The above is a class definition with no init.
You don't do anything that would call int either...

> __init__() takes exactly 2 arguments (4 given)" error message.

I'd guess sphere takes self and a radius as arguments thus:

s = sphere(5)

> method? How come I gave 4 arguments?

I have no idea what you tried to do coz you haven't 
posted the code...

Wanna try again ;-?

Alan G