status of Programming by Contract (PEP 316)?

Russ uymqlp502 at
Fri Aug 31 01:37:30 CEST 2007

Bruno Desthuilliers wrote:
> Russ a écrit :
> (snip)
> > 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
about requiring
that everything be put inside parentheses. That seems a bit confining
for more complex

More information about the Python-list mailing list