Debugging Python ?
Michael Sparks
zathras at thwackety.com
Mon Jul 28 12:08:35 EDT 2003
On Mon, 28 Jul 2003, Shane Hathaway wrote:
> As a bonus, I find that print statements do not rightfully belong in
> most of the software I write. Therefore I can happily add print
> statements anywhere for debugging purposes, knowing that removing them
> later is perfectly safe.
As an extra bonus, if you do this you can remove them all automatically:
def print(*args):
for arg in args:
print arg,
return True
assert print("Well, well, well", "said", "he")
To erase all tracks of the debugging statements at runtime, just use the
-O flag. I tend to use a variant of this for debugging systems that have
"complex" concurrency to make it simpler to track "who" "said" what.
I know you can do the same with just grep if you use print - but you have
to ensure that your debugging statements don't span multiple lines.
Michael.
More information about the Python-list
mailing list