idioms for abstract base classes
Carlos Ribeiro
cribeiro at mail.inet.com.br
Wed Apr 25 07:25:41 EDT 2001
At 13:18 24/04/01 -0700, zooko at zooko.com wrote:
>Eventually, we started just undoing the inheritance -- I changed
>CryptoCommsHandler to just implement all of its methods instead of using
>any of
>the ones inherited from BaseCommsHandler, and next time I touch
>TCPCommsHandler
>I'll do the same to it. Then we can nuke DummyCommsHandler (which is only
>good
>for testing the unused "chaining" feature anyway) and CommsHandler and
>BaseCommsHandler. It will feel really good to get rid of those after all the
>trouble they've caused.
This is the kind of problem that could be solved with interfaces. We had a
lot of discussions on that, and the PEPs are still pending. The discussion
is (as far as I recall) if Python needs some explicit support for
interfaces. Some people feel that we can use interfaces nicely in Python
today, just by documenting it carefully, and using the dynamic nature of
the language. You are not trapped by a rigid hierarchy; object similarities
are handled through their support of interfaces, instead of using inheritance.
Carlos Ribeiro
More information about the Python-list
mailing list