On Mon, 03 Jun 2013 03:20:52 +1000, Chris Angelico wrote: > On Mon, Jun 3, 2013 at 3:04 AM, Rick Johnson > <rantingrickjohn...@gmail.com> wrote: >> * Woefully inadequate because: Switching on or off the debug >> messages is only valid in the current module that the function was >> imported. What if you want to kill all debugprint messages >> EVERYWHERE? Do you really want to edit "debug = BOOLEAN" in every >> source file OR do something stupid like import debugprint and edit >> the DEBUG constant OR even dumber, edit the debugprint source >> code? GAWD NO! > > Easy fix to this one. Instead of copying and pasting debugprint into > everything, have it in a module and import it everywhere. Then the > debug flag will be common to them all.
Or use the logging module. It's easy to get going quickly (just call logging.basicConfig at startup time), and with a little care and feeding, you can control the output in more ways than can fit into the margin. Oh, yeah, I'm sure it introduces some overhead. So does everything else. >> * But even if you are willing to cope with all the "switch- >> on-and-off" nonsense, are you willing to have you code slowed by >> numerous calls to a dead function containing a comparison that >> will always be false? > > Hmm. Could be costly ... Yeah, all that time that I have left over and have to find something else to do instead of debugging my program. What a waste! ;-) Dan -- http://mail.python.org/mailman/listinfo/python-list