Basel Shishani
Basel Shishani

Reputation: 8177

Activating set_trace() selectively at runtime in pdb or sisters

In pdb/ipdb/pudb, is there a trick whereby I can selectively activate set_trace() statements during runtime?

I'm debugging somewhat complex code with probabilistic behavior, and I would like to interact with the program without the debugger distracting, and when a situation of interest arises, activate the set_trace/s. (This is combined with logging, but not relevant to the question).

I think might be possible to do this with conditionals, but is there a better way?

Upvotes: 0

Views: 174

Answers (2)

JS.
JS.

Reputation: 16097

In pudb, you can set a breakpoint, then edit the breakpoint to be skipped a given number of times or only trigger on a given condition.

Upvotes: 0

Beka
Beka

Reputation: 745

I think there is no such way, as pudb (and the other debuggers) can only set_trace() unconditially.

I'm not sure what you are trying to accomplish by moving the condition into set_trace() itself.. If you have some repetitive code there, just wrap it in a function.

Upvotes: 1

Related Questions