status of Programming by Contract (PEP 316)?

Russ uymqlp502 at sneakemail.com
Fri Aug 31 16:27:19 EDT 2007


Steve Holden wrote:

> Well that's a healthy attitude, but I am concerned that the Python
> community should be as welcoming as possible, so I don't like the fact
> that you feel you are being treated differently from anyone else.

I certainly appreciate that. And I will try my best to refrain from
the little personal zingers (and
the big ones too).

> > All you really need to test the pre-conditions of a function
> > is a call at the top of the function to another function that checks
> > the inputs. To test the
> > post-conditions, you just need a call at the bottom of the function,
> > just before the return,
> > that checks the return values. Those functions can also check the
> > invariants. Then you
> > define a global variable to switch all the self-test functions on or
> > off at once.
> >
> It does constrain functions to return only from the bottom of their
> code, though, which not all Python functions currently do. Though
> there's nothing to stop you putting the calls before every return.

Oops! I didn't think of that. The idea of putting one before every
return certainly doesn't
appeal to me. So much for that idea.




More information about the Python-list mailing list