[Python-ideas] Why is design-by-contracts not widely adopted?
rosuav at gmail.com
Fri Sep 28 20:12:27 EDT 2018
On Sat, Sep 29, 2018 at 7:19 AM Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Chris Angelico wrote:
> > It is still fundamentally difficult to make assertions about the file
> > system as pre/post contracts.
> When you consider race conditions, I'd say it's impossible.
> A postcondition check involving the file system could fail
> even if the function does its job perfectly.
I guess that depends on the meaning of "contract". If it means "there
is a guarantee that this is true after this function returns", then
yes, the race condition means it's impossible. But as a part of the
function's declared intent, it's fine to have a postcondition of "the
directory will be empty" even though something could drop a file into
But if it's the latter... contracts are just a different way of
defining unit tests.... and we're right back where we started.
More information about the Python-ideas