status of Programming by Contract (PEP 316)?
arkanes at gmail.com
Fri Aug 31 01:50:59 CEST 2007
On 8/30/07, Russ <uymqlp502 at sneakemail.com> wrote:
> 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
This is existing, working python syntax (although the decorators would
need to be defined).
More information about the Python-list