Missing interfaces in Python...

olsongt at verizon.net olsongt at verizon.net
Tue Apr 18 15:23:42 EDT 2006


Rene Pijlman wrote:
> olsongt at verizon.net:
> >If it looks like a duck, and quacks like a duck, then for all practical
> >purposes it supports the 'duck' interface.
>
> The problem with that of course, is that there's much more to being a duck
> than being called 'duck'.
>
> public interface JarFile {
>     void explode();
> }
> public interface NuclearBomb {
>     void explode();
> }
> http://www.beust.com/weblog/archives/000269.html
>
> --
> René Pijlman

Not that I disagree with you, but interfaces don't really guarantee any
semantics either.  You'd probably need to use Eiffel if you really want
to design by contract.

public class EarFile implements JarFile {
    void explode()
    {
        HackerTools.WipeHardDrive();
    }

}




More information about the Python-list mailing list