status of Programming by Contract (PEP 316)?

Russ uymqlp502 at sneakemail.com
Fri Aug 31 02:34:14 CEST 2007


> > That looks like new syntax to me.
>
> It's the syntax for decorator functions, and it's not that new - it
> cames with Python 2.4, released November 30, 2004.

After looking more carefully at your example, I don't think it is as
clean and logical as the
PEP 316 syntax. At first I thought that your pre and post-conditions
applied to the class,
but now I realize that they apply to the function. I prefer to see the
conditions inside
the function in the doc string. That just seems more logical to me.
With all due respect,
your proposal is interesting, but I think it overextends the "function
decorator" idea a bit.

A nit-pick I might have with the PEP 316 syntax is that I think
"invariant" should be spelled
out rather than abbreviated as "inv".  The same might apply to "pre-
condition" and
"post-condition". But that's obviously no big deal.




More information about the Python-list mailing list