debugging code

beliavsky at aol.com beliavsky at aol.com
Tue Apr 27 15:39:18 EDT 2004


If I have some debugging code in a Python program (mostly print
statements) and I want to turn it "off", two obvious methods are to
(1) comment out the code 
(2) set a logical 'debug' variable at the beginning and use it to
conditionally run the debugging code.

Is there a better way? Some other languages have conditional
compilation. (I don't know if that is better or worse). What is the
"best" way to maintain "production" and "debugging" versions of a
Python program at the same time, preferably in the same file?



More information about the Python-list mailing list