Creating subclassess (newbie)

Piet van Oostrum piet at cs.uu.nl
Tue Jun 22 21:11:09 EDT 2004


>>>>> Adam <adamc at linuxmail.org> (A) wrote:

A> I have tried to send this to the tutor mailing list, but it
A> seems to be down at the moment. 

A> I have a subclass I want to create- my intuition told me
A> that it would be done like this:

A> class MainClass:
A> 	class SubClass:
A> 		code...
A> 	subclassinstance = SubClass()
A> mainclassinstance = MainClass()

A> But it seems that this isn't going to work. I'm reading a
A> couple of Python books, but they don't seem to cover this
A> topic very well (I don't see any coding examples).

I can't imagine that the Python books don't tell this.

A> What is the best way of creating (coding) subclasses?
A> Alternatively, is there any good documentation on the web
A> for doing this? 

I guess every Python introduction tells you:

class MainClass:
        ....

class SubClass(MainClass):
        ....

mainclassinstance = MainClass()
subclassinstance = SubClass()
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list