Am I missing something with Python not having interfaces?

Rhamphoryncus rhamph at gmail.com
Sat May 10 12:02:11 EDT 2008


On May 9, 1:53 pm, Daniel Marcel Eichler <onsen-n... at gmx.net> wrote:
> Am Freitag 09 Mai 2008 10:19:45 schrieb Bruno Desthuilliers:
>
> > >> very often sees do-nothing catch-all try/catch blocks in Java -
> > >> which is way worse than just letting the exception propagate. I
> > >> find all this totally pointless, because there's just no way for a
> > >> compiler to check if your code is logically correct.
>
> > > But it's enough if the called method exists and returns the correct
> > > type. At least it prevents a crash.

The application has already failed.  You'd prefer it silently do the
wrong thing than get an explicit error message and stop?


> > >>> That's the point. Interfaces garantee that a duck is a duck, an
> > >>> not only a chicken that quack.
>
> > >> Who cares if it's a chicken as long as it quacks when you ask her
> > >> to ? Now *This* is the whole point of chicken^Mduck typing, isn't
> > >> it ?-)
>
> > > Ducks can also swim and fly.  And if you need a really duck,
>
> > If you're code expects something that quacks, swims and flies,
> > anything that quacks, swims and flies is ok. You just don't care if
> > it's a duck or a flying whale with a quacking device tied to it.
>
> Not the point.

It really is.  They're only going to give you something they expect to
work.  They might occasionally make a mistake and give you garbage,
but it's not worth the effort of trying to catch it early.




More information about the Python-list mailing list