is this the right way to do subclasses?

John Salerno johnjsal at NOSPAMgmail.com
Wed Nov 8 22:36:02 CET 2006


John Salerno wrote:
> Peter Otten wrote:
> 
>> Try it: Fighter(...) will implicitly call Character.__init__(...).
> 
> Ok, I'm confused! :) I thought you had to explicity call a base class's 
> __init__ method? How is it doing this?

Wait, I just might be an idiot. Is it not even necessary for me to call 
Character's __init__ method? Fighter will inherit it automatically and 
call it when a Fighter object is created, right?

If that's the case, then I don't know what I was thinking! I guess I was 
thinking more along the lines of how in wxPython, when you subclass a 
Frame, you have to call Frame.__init__, but maybe that's only because 
you then do your own stuff in a custom __init__ class, which would have 
otherwise overridden the Frame.__init__.

In this case, I need Character.__init__ and nothing else, right? Now 
your other method is making sense to me too! :)



More information about the Python-list mailing list