status of Programming by Contract (PEP 316)?

Russ uymqlp502 at
Fri Aug 31 20:40:30 CEST 2007

Steve Holden wrote:

> Frankly I am getting a little tired of they way you are unable to even
> recognize that your readers may well have a sensible appreciation of the
> difficulties about which you write. As has been pointed out already,
> many readers here are extremely experienced programmers.

> You said in an earlier post "that's not an insult", but that isn't
> really up to you to decide. If it gives offense then it probably is,
> whether it was intended to do so or not. You don't seem to appreciate
> the insulting nature of your tone, and calling people bozos is not
> likely to endear you to most readers since it comes off as arrogant.

You quoted what I wrote in reply to a personal attack against me, but
you conveniently
neglected to quote the original insult that I was replying to. OK,
I'll concede that I shouldn't
have replied to a personal insult with another insult, but why am I
the only one at fault here
rather than the guy who started it?

Frankly, Mr. Holden, I'm getting a bit tired of the clannish behavior
here, where
"outsiders" like me are held to a higher standard than your "insider"
friends. I don't know
who you are, nor do I care what you and your little group think about

As for DbC or what I call "self-testing code," I have come to the
(tentative) realization that
it is easy to implement in current Python -- without resorting to the
"decorators" hack.
OK, maybe this should have been obvious to me from the
start, but here goes:

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.

An advantage of this approach is that all the self tests can be put at
the bottom of the file
(or perhaps in another file) to reduce "clutter" in the primary code.

I'd still prefer PEP 316, but this seems like a reasonable

One suggestion I have for PEP 316 is to provide a way to place the
checks in a separate file to reduce clutter.

More information about the Python-list mailing list