Using debug print routine inside assert

Edvard Majakari edvard+news at
Tue Nov 4 15:13:22 CET 2003

Peter Hansen <peter at> writes:


> My solution has been to dispense completely with "debugging code" 
> except *during* debugging (when a print or two might appear temporarily,
> or a call to pdb.set_trace()), and instead do all my development using
> unit tests.

Now, if I had to name a person for Father of All Unit Testing Advocates, I
think I knew who'd I name... ;)

> With adequate use of the "unittest" standard module, I haven't encountered
> any reason to call one of those old debug() routines or have a global
> "debug level" variable for eons...

Personally, I think you're right. I've become fascinated with the idea of
unit testing myself, but the problem is that 

a) you often have to find out bugs from somebody else's code

b) you've developed system using testing, but the bug didn't appear in
   your tests and now you don't know what causes the problem 

c) you didn't do unit testing yet when you coded the module or

d) you don't believe in unit testing

to which we'd say d is the wrong answer, c is more likely and a and b just

#!/usr/bin/perl -w
69,19,20,6,64,27,61,22,72};$_=join'',map{chr hex $h->{$_}}sort{$a<=>$b}
keys%$h;m/(\w).*\s(\w+)/x;$_.=uc substr(crypt(join('',60,28,14,49),join'',
map{lc}($1,substr $2,4,1)),2,4)."\n"; print;

More information about the Python-list mailing list