Python "implements <interface>" equivalent?
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Wed Oct 3 22:38:25 EDT 2007
Lawrence D'Oliveiro a écrit :
> In message <1191510706.528876.261780 at 57g2000hsv.googlegroups.com>, Wojciech
> Gryc wrote:
>
>
>>I'm a seasoned Java programmer and quite a big fan of interfaces...
>>i.e. The idea that if I make a number of distinct classes that
>>implement interface X, I can pass them all as parameters to functions
>>or whatnot that require an X object.
>
>
> Why?
>
> Interfaces are just a euphemism for multiple inheritance,
Java's 'interface' mechanism is mostly a (somewhat weak & dumb IMHO)
mean to decouple (sub)typing from implementation. Given a declarative
static type system and the restriction to single implementation
inheritance, of course. IIRC, vb6 had *no* implementation inheritance at
all - you had to do 'implement' it by yourself, using (manual of course)
delegation...
Now multiple inheritence is clearly not the answer to the OP's question
in a dynamically typed language, where subtyping is not bound to
inheritance.
More information about the Python-list
mailing list