status of Programming by Contract (PEP 316)?

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Thu Aug 30 14:59:19 CEST 2007


Russ a écrit :
> 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. 

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

> Did I miss your point?

Yes.



More information about the Python-list mailing list