How can I make my assertions smarter?

Stuart Hungerford stuart.hungerford at
Wed Nov 3 09:15:12 CET 1999

Tim Peters wrote:

> [Stuart Hungerford, desperately hoping that design by contract will
>  be easier in Python if he calls it by some other name ...]

   I'd kind of given up on true DBC, and just went with loads of asserts
   as ersatz pre and postconditions. When I find myself calling the same
   construct hundreds of times, I can't help but feeling I may be able to
   do things either more conveniently, more flexibly or with more value
   added.  Hence my question.

> > I'm using some simple functions to implement crude precondition,
> > postcondition and invariant checking in Python classes.
> >
> > (Tim: please be gentle ;-)
> I am always gentle with you, Stuart!  Your heart is in the right place --
> although it may as well be firmly stuck up your ass for all the good it's
> doing you <wink>.

   This must be the Python equivalent of "tough love" ;-)   Top of my
   new years resolutions list is not to post any more DBC in Python

   Thanks to everyone who responded to this question -- I've learnt some
   interesting and useful techniques in the process.



More information about the Python-list mailing list