Are there 'Interfaces' in Python??
unknown at lee-morgan.net
Thu Sep 27 10:11:41 CEST 2001
"Brian Quinlan" <BrianQ at ActiveState.com> writes:
> Aside from the fact that this would not fit at all with the rest of
> Python, from a philosophical point of view, it would also require a
> complete revamp of the Python compilation semantics to work (imports
> would have to be evaluated a compile-time, type-checking would have to
> be done at compile-time, etc.).
> Paul Prescod (leader of the types SIG) has done some thinking about
> interfaces in Python but, in his model, they would be runtime
> constructs like everything else.
> Actually, the more I think about, the more your idea horrifies me :-)
Aghast, don't be horrified, its only an idea :-)
Dynamic types, late binding and guaranteed tracebacks are great, but if you're
targeting production code you want to handle errors gracefully and ensure
interfaces are implemented. A pretty traceback is a powerful tool in my hands,
but in my customers...
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
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!
Enlightenment welcome, cheers
More information about the Python-list