Caleb Hattingh a écrit :
> Peter
> 
> To my mind, this kind of setup (interface class, or abstact class

are two different things.

>) is 
> more  usually used in static languages  

True.

 >to benefit polymorphism

This is a good reason to use an interface in Java. C++ has no notion of 
'interface', so you have to use abstract classes to achieve the same result.

> - but 
> python is  dynamically typed, so in which situations would this setup be 
> useful in a  python program? 

Abstract classes ? When you want to factor out common implementation in 
a base class and force derived class to implement specific parts. One 
common use case is the template method (aka "hollywood", aka "don't call 
us, we'll call you") pattern.

> You see, I expected your post to say that 
> it wouldn't  even be necessary, but you didn't :)

Implementation inheritance is never "necessary". Nor are OO, modularity, 
structured programming, and human-readable programming languages !-)

It's a fact that inheritence being "only" (err... should I say "mostly" 
?) an implementation mechanism in dynamic languages, class hierarchies 
tends to be much more flat. But this doesn't mean that abstract base 
classes are useless.

> I have spent a little effort training myself not to bother setting up  
> class hierarchies like this in python

I had this pattern too.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to