[Python-ideas] Pre-conditions and post-conditions
Greg Ewing
greg.ewing at canterbury.ac.nz
Mon Sep 3 18:50:27 EDT 2018
Jonathan Fine wrote:
> I've just read and article which makes a good case for providing
> pre-conditions and post-conditions.
>
> http://pgbovine.net/python-unreadable.htm
There's nothing in there that talks about PBC-style executable
preconditions and postconditions, it's all about documenting
the large-scale intent and purpose of code. He doesn't put
forward any argument why executable code should be a better
way to do that than writing comments.
Personally I don't think it is. E.g.
def distim(doshes):
for d in doshes:
assert isinstance(d, Dosh)
# do something here
for d in doshes:
assert is_distimmed(d)
This ticks the precondition and postcondition boxes, but
still doesn't give you any idea what a Dosh is and why
you would want to distim it.
--
Greg
More information about the Python-ideas
mailing list