I am trying to track down when a variable gets updated. I have a watcher, but is there any way to set it up so that the execution can be paused when the value is getting updated?
This is called a watchpoint or a data breakpoint.
I am trying to track down when a variable gets updated. I have a watcher, but is there any way to set it up so that the execution can be paused when the value is getting updated?
This is called a watchpoint or a data breakpoint.
Currently pycharm does not have a default built-in feature that tracks variable modification in real time. Alternatively you can do this:
The feature you are talking about is, I believe, called watchpoint support and according to this article: http://sourceforge.net/blog/watchpoints-in-python/ Eric and PyScriptor has the feature but not pycharm.
Checkout watchpoints:
watchpoints is an easy-to-use, intuitive variable/object monitor tool for python that behaves similar to watchpoints in gdb.
An answer to How do you watch a variable in pdb describes how it compares to other approaches and why it's favorable.
As for better integration with pycharm, see Support other debuggers like pydevd
Regarding built-in python support and performance impact, see:
Further notes are available on other questions on SO:
breakpoint()
or pydevd.settrace()
might be a solution if more control is neededLastly, I repeat the proposal to vote for Support Data breakpoints PyCharm issue.
You can add a breakpoint in the line you need to watch and right-click it. Then in the dialog box you have "condition" as last input: add a condition that uses the variable you need and it should stop when you set it to.