Re: Using debug print routine inside assert
From: Richard Brodie (R.Brodie_at_rl.ac.uk)
Date: 11/04/03
- Next message: Svenne Krap: "Re: Selling Python Software"
- Previous message: Alex Martelli: "Re: Please explain the meaning of 'stealing' a ref"
- In reply to: Edvard Majakari: "Using debug print routine inside assert"
- Next in thread: Alex Martelli: "Re: Using debug print routine inside assert"
- Reply: Alex Martelli: "Re: Using debug print routine inside assert"
- Reply: Edvard Majakari: "Re: Using debug print routine inside assert"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 4 Nov 2003 14:22:32 -0000
"Edvard Majakari" <edvard+news@majakari.net> wrote in message
news:8765i072jh.fsf@titan.staselog.com...
> Today I shortly discussed the problems in using print statements for
> debugging problems in Python. Often in coding, in addition to asserts it
> is nice to have a debug routine like
> # somewhere in the program
> debug("subfrobnicate(%s, %s) returned %s" %(p1, p2, subfrobnicate(p1, p2)))
>
> The idea here is to have consistent debug print messages. However,
> parameters or expressions inside the debug statement might be very
> time-consuming to run.
I'm not sure how often you would need to write:
debug("subfrobnicate(%s, %s) returned %s" %(p1, p2, subfrobnicate(p1, p2)))
without having called subfrobnicate in the main code. Assuming that you do,
though, it's relatively easy to juggle around the code by having something like:
def defer(f, *args):
f(*args)
and writing:
debug("subfrobnicate(%s, %s) returned %s" % (p1, p2, defer(subfrobnicate, p1, p2)))
Also note that Python now has a standard logging module since 2.3:
http://www.python.org/doc/2.3/whatsnew/
- Next message: Svenne Krap: "Re: Selling Python Software"
- Previous message: Alex Martelli: "Re: Please explain the meaning of 'stealing' a ref"
- In reply to: Edvard Majakari: "Using debug print routine inside assert"
- Next in thread: Alex Martelli: "Re: Using debug print routine inside assert"
- Reply: Alex Martelli: "Re: Using debug print routine inside assert"
- Reply: Edvard Majakari: "Re: Using debug print routine inside assert"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|