Are there 'Interfaces' in Python??

Markus Schaber markus at schabi.de
Thu Sep 27 04:54:29 EDT 2001


Hi,

Lee Morgan <unknown at lee-morgan.net> schrub:

> I don't understand what runtime interfaces get you at all. From my
> distant memory of Java a class implements an interface, and therefore
> guarantees its existence.
> 
> Ah haa - maybe I get it now, do you mean python interface's would
> supply the base interface which you could override? And if so wouldn't
> the type/class unification provide a cleaner way of doing it? Or would
> an interface just guarantee some base class's __init__ is called?
> 
> Hmm, I should really read the Interface PEP!

I would agree.

As far as I remember, you ask the object in question to give you a 
specific interface, and the object returns an instance that is 
guaranteed to implement the interface (could be the object itsself or a 
wrapper). When this fails, maybe the interface itsself knows how to 
wrap around the object and can create such one.

markus
-- 
"The strength of the Constitution lies entirely in the determination of 
each citizen to defend it. Only if every single citizen feels duty 
bound to do his share in this defense are the constitutional rights 
secure." -- Albert Einstein



More information about the Python-list mailing list