[Python-ideas] Why is design-by-contracts not widely adopted?

David Mertz mertz at gnosis.cx
Fri Sep 28 08:23:44 EDT 2018

On Thu, Sep 27, 2018, 9:25 PM Marko Ristin-Kaufmann <marko.ristin at gmail.com>

> Try to question whether the contracts I wrote are so obvious to everybody
> even if they are obvious to you and keep in mind that the user does not
> look into the implementation.

I had missed this comment, but this seems to be the biggest disconnect, or
talking past each other.

I'm a user of many libraries. I USUALLY look at the implementation when in
doubt about a function. If contracts are meant only for users who don't
look at code, the detrimental effect on code readability is mitigated.

The other place I look, if not the actual implementation, is at the
docstring. I don't remember if icontracts patches the docstring when it
decorates a function. If not, that would be very helpful.

I agree that all the Sphinx documentation examples shown are very nice.
Prose descriptions would often be nicer still, but the Boolean expressions
are helpful for those unusual cases where I don't want to look at the code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180928/8b210627/attachment-0001.html>

More information about the Python-ideas mailing list