SparkAndShine
SparkAndShine

Reputation: 18037

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?

Upvotes: 1

Views: 125

Answers (1)

Luke Codewalker
Luke Codewalker

Reputation: 306

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.

Upvotes: 1

Related Questions