Re: Interfaces != Multiple Inheritance [was Re: python development practices?]
by Andrew Dalke other posts by this author
Oct 31 2001 2:25AM messages near this date
Re: python development practices?
|
Re: Interfaces != Multiple Inheritance [was Re: python development practices?]
Richard Jones:
> Java interfaces != multiple inheritance.
>
> They address completely different issues. Mutliple inheritance allows one
to
> include functionality from multiple base classes in one step. An interface
> indicates that your class implements a specific set of methods. Interfaces
> don't implement functionality, therefore indicating that your class
> implements multiple interfaces doesn't add any additional functionality.
Who says the base class needs to implement functionality?
class SpamInterface:
def sing(self):
raise NotImplementedError
class EggsInterface:
def fry(self):
raise NotImplementedError
class Food(SpamInterface, EggsInterface):
def sing(self):
return "Spam, spam, spam, spam!"
def fry(self):
return "Sizzle."
issubclass(Food, SpamInterface)
For that matter, who says that espousing an interface means that
interface is properly implemented? Since you have to have the
regression tests anyway, what's the point of declaring an interface
when the act of testing it is sufficient to show that the needed
API is available?
Andrew
dalke@[...].com
--
http://mail.python.org/mailman/listinfo/python-list
Thread:
Peter Wang
Peter Hansen
Toby Dickenson
Tim Peters
Steve Holden
Steve Holden
Cliff Wells
Tim Peters
Martijn Faassen
Cliff Wells
Cliff Wells
Martijn Faassen
Martijn Faassen
Paul Rubin
Russell E. Owen
Barry A. Warsaw
Martijn Faassen
Peter Wang
Skip Montanaro
John Roth
David Bolen
Peter Wang
Peter Wang
Skip Montanaro
Chris Tavares
Darren Collins
David Bolen
Paul Rubin
Paul Rubin
Peter Wang
F Basegmez
Richard Jones
Richard Jones
Neal Norwitz
Graham Ashton
Peter Wang
Russell E. Owen
Skip Montanaro
Cliff Wells
Hung Jung Lu
Wade Leftwich
Peter Wang
Peter Wang
Peter Wang
Chris Gonnerman
Paul Rubin
Andrew Dalke
Paul Rubin
Luigi Ballabio
Paul Rubin
Tim Peters
John Roth
Paul Rubin
Richard Jones
|