Why PEP 245??

Alex Martelli aleaxit at yahoo.com
Wed May 30 03:23:01 EDT 2001


<nanotech at europa.com> wrote in message
news:mailman.991174903.6105.python-list at python.org...
    ...
>     The purpose of an interface is to document how
>     to work with an object, not how the object is
>     implemented.
>
> If this is all (or a large part), then why not just doc-strings? With

docstrings are not executable and hence not rigorous.  Code is
preferable to comments (and docstrings) because it does not
"get out of sync", or if it does that shows at once.  (docstrings
can have executable _examples_ thanks to doctest of course,
but that's not an executable 'spec').

> Basically, without some sort of "compile-time" check that classes
    ...
> But what enforces the contract?

If not compile-time, then run-time, of course.  What else?

> PS: Where do mixin classes fit? Or have they gone out of style?

No, why?  An object can implement multiple interfaces, of course.


Alex






More information about the Python-list mailing list