status of Programming by Contract (PEP 316)?
uymqlp502 at sneakemail.com
Fri Aug 31 01:37:30 CEST 2007
Bruno Desthuilliers wrote:
> Russ a écrit :
> > I don't see how you can avoid adding some new syntax, given that
> > Python does not
> > currently have syntax for specifying invariants and pre- and post-
> > conditions.
> class Parrot(object):
> @pre(lambda x : x != 42)
> @post(lambda result: result != 42)
> @invariant(lambda self: self.x == 42)
> def reliable_method(self, x):
> # your code here
> return something
That looks like new syntax to me. Did I miss your point?
I have no strong leaning about what the exact syntax should be for
programming by contract.
The syntax you show above seems reasonable, except that I am not sure
that everything be put inside parentheses. That seems a bit confining
for more complex
More information about the Python-list