[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Function Inheritance



On Wed, Oct 14, 2009 at 10:37:41PM -0400, Kris Schnee wrote:
> Kevin wrote:
> >Don't forget Python supports multiple inheritance as well, which can be 
> >very useful.
> 
> So that'd be like so:
> 
> class Basic:
>   def __init__(self):
>     pass
>   def DoStuff(self):
>     print "Hello World"
> 
> class Advanced( Basic, SomeOtherClass ):
>   def __init__(self):
>     Basic.__init__(self)
>     SomeOtherClass.__init__(self)
> 
> Basically, putting my basic functions into a class just for the sake of 
> copying them all over into a new class at once. I thought multiple 
> inheritance was kind of frowned upon...? But it does sound like the best 
> route to do what I'm doing in a tidy and reliable way. Thanks to everyone.

I think it is mostly frowned upon in other languages because of 
ambiguity over which parent takes priority. I don't think that is an 
issue with python.

I think another reason it is frowned upon is that if you go overboard 
with it you can end up with a needlessly complicated class heirarchy.

But used in moderation with an understanding of how it works, you should 
be fine with it.

But perhaps someone else knows some complaints about multiple 
inheritance that I am not aware of...

---
James Paige