[Python-ideas] Why is design-by-contracts not widely adopted?
barry at barrys-emacs.org
Mon Sep 24 13:39:21 EDT 2018
> On 23 Sep 2018, at 11:13, Angus Hollands <goosey15 at gmail.com> wrote:
> 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 - https://github.com/agoose77/pyffel <https://github.com/agoose77/pyffel>
> It is by no means well written, but a fun PoC nonetheless.
This is an interesting PoC, nice work! I like that its easy to read the tests.
Given a library like this the need to build DbC into python seems unnecessary.
What do other people think?
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas