is this the right way to do subclasses?

Steve Holden steve at holdenweb.com
Wed Nov 8 17:35:34 EST 2006


John Salerno wrote:
> 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?
> 
By Jove, he's got it!

> 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! :)

Nice one.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list