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

Angus Hollands goosey15 at gmail.com
Sun Sep 23 06:13:59 EDT 2018

Hi Marko,

I think there are several ways to approach this problem, though am not
weighing in on whether DbC is a good thing in Python. I wrote a simple
implementation of DbC which is currently a run-time checker. You could,
with the appropriate tooling, validate statically too (as with all
approaches). In my approach, I use a “proxy” object to allow the contract
code to be defined at function definition time. It does mean that some
things are not as pretty as one would like - anything that cannot be hooked
into with magic methods i.e isinstance, but I think this is acceptable as
it makes features like old easier. Also, one hopes that it encourages
simpler contract checks as a side-effect. Feel free to take a look -
It is by no means well written, but a fun PoC nonetheless.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180923/7d7afc71/attachment.html>

More information about the Python-ideas mailing list