Using debug print routine inside assert

Richard Brodie R.Brodie at rl.ac.uk
Tue Nov 4 11:33:07 EST 2003


"Alex Martelli" <aleax at aleax.it> wrote in message news:0cPpb.91638$e5.3380437 at news1.tin.it...
> Richard Brodie wrote:
>    ...
> > def defer(f, *args):
> >         f(*args)
>
> Hmmm, this doesn't defer anything -- the moment you call defer, it in
> turns calls f _at once_.

Yeah, I was just sketching out a pattern on how to write the debug routine
but overedited it to omit the if (debug) part. Then compounded my error
by conflating the two debug implementations later.

Thanks for expressing more clearly and correctly what I was thinking.

On the unittest vs. logging debate: logging can be useful at the level, where
you couldn't deduce from the code what should be happening. For
example, if you have to interoperate with third-party, possibly buggy clients.
"What requests have been rejected as malformed?" is a question unit tests can't
address. OTOH if you are adding debug code to find how an individual unit
works, that probably is bad practice.










More information about the Python-list mailing list