Missing interfaces in Python...

Roy Smith roy at panix.com
Wed Apr 19 08:29:12 EDT 2006


In article <1he0aen.324fes1th8n52N%aleaxit at yahoo.com>,
 aleaxit at yahoo.com (Alex Martelli) wrote:

> Roy Smith <roy at panix.com> wrote:
> 
> > Peter Maas  <peter.maas at somewhere.com> wrote:
> > > He probably means that with interfaces one could test compliance
> > > with the interface as a whole instead of testing each member and
> > > each signature as a single piece.
> > 
> > All interfaces (as implemented by Java) prove is that your class has a
> > bunch of methods with the right names and signatures.  It doesn't
> > prove that those methods do the right things.  It's like having a
> 
> There's a _tiny_ bit more -- accidental clashes of methodnames are more
> likely to be avoided.  I.e.,
> 
> interface ILottery {
>     void draw();
> };
> 
> interface IGunslinger {
>     void draw();
> };
> 
> interface IPainter {
>     void draw();
> };
> 
> A class asserting, e.g., "implements IPainter", doesn't thereby risk
> being accidentally misused where an IGunslinger is required (OTOH,
> implementing >1 of these IS a bother, but that's sort of inevitable).

I suppose, but all you've really done is move the problem to a different 
namespace.  Which IPainter did you have in mind?  The one that has to do 
with people who apply oils to canvas, or the one that has to do with ropes 
that are used to tie up rowboats?



More information about the Python-list mailing list