Search code examples
pythondebuggingpycharmpydev

How to detect where a variable is changed in Python?


I would like to find out where a specified variable is changed with debugger tools, but fail to do that after several hours exploring both Eclipse + PyDev and PyCharm.

var = foo()
print(var)

bar(var)  # var is changed after calling bar(var), where is it changed? 
print(var) # var is changed

There is no Toggle Watchpoint in PyDev. Use Breakpoint properties? What is the condition I should type in?


Solution

  • Try using @property setters . Then put a detect in the setter to see when the value changes. Search online to find out more or a good book is: Effective Python" Good luck.