-- 
Oook,
J. Cliff Dyer
Carolina Digital Library and Archives
UNC Chapel Hill
--- Begin Message ---
On Wed, 2008-05-07 at 21:19 +0200, Daniel Marcel Eichler wrote:
> Am Dienstag 06 Mai 2008 16:07:01 schrieb Mike Driscoll:
> 
> > If so, then it looks like an Interface is a generic class with method
> > stubs. You can do that with Python just as easily by creating empty
> > methods with just the "pass" keyword. 
> 
> Well, no. It's a litte different. Interfaces force to implement methods. 
> Simple inheritance with method-stubs can't garantee that a specific 
> method is reimplementat in a sub-class. Interfaces work at 
> compile-time, while method-stubs raise at their first call, so in worst 
> case, never (when the developer is available). 
> 
> > Since it's just a construct to implement polymorphism, I don't think
> > you'll lose anything. However, Python does not require you to re-
> > implement every method of the class it is inheriting from. 
> 
> That's the point. Interfaces garantee that a duck is a duck, an not only 
> a chicken that quack. 
> 

Which, in spite of your rhetorical flourish, is the exact opposite of
duck typing.  Duck typing means that if you're looking for quacking
behavior, and you find a quacking chicken, it's close enough.

Sometimes you need that kind of rigor, and you can get it as easily as 

>>> from zope3 import interfaces 

(or whatever the actual import line is), but it's not how python behaves
out of the box.  


> > You can just override those that you want and leave the others alone.
> 
> Not always desirable. But often enough ;)
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

--- End Message ---
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to