Hi,
Thank you for ipdb, I use it so much, and most of my code has permanent ipdb statements in it that can be activated with certain debug flags, i.e. I might have a loop and within I'd call ipdb.set_trace() with a condition, e.g.:
for match in tournament.get_matches(
include_played=True, include_not_ready=True
):
ipdb.set_trace(cond=match.id in self.debug_match_ids)
When the condition matches, I almost always find myself hitting match.id into the prompt to know what match I am on. This made me think that I'd love to be able to pass a message to set_trace such that when the debugging session starts, the message is printed and gives me context:
ipdb.set_trace(
cond=match.id in self.debug_match_ids,
message=f"Entering interactive debugger on match {match.id}"
)
which would yield something like:
> /home/madduck/squash/tc/tcboard/tcboard/board.py(151)process_tournament()
150 ):
--> 151 ipdb.set_trace(
152 cond=match.id in self.debug_match_ids,
153 message=message=f"Entering interactive debugger on match {match.id} …"
154 )
Entering interactive debugger on match 80-6 …
ipdb>
Of course, I can do this with a wrapper and writing to sys.stderr, but I figure that if cond exists, then sso could message.
What do you think?
Hi,
Thank you for ipdb, I use it so much, and most of my code has permanent
ipdbstatements in it that can be activated with certain debug flags, i.e. I might have a loop and within I'd callipdb.set_trace()with a condition, e.g.:When the condition matches, I almost always find myself hitting
match.idinto the prompt to know what match I am on. This made me think that I'd love to be able to pass a message toset_tracesuch that when the debugging session starts, the message is printed and gives me context:which would yield something like:
Of course, I can do this with a wrapper and writing to
sys.stderr, but I figure that ifcondexists, then sso couldmessage.What do you think?