[wingide-users] breakpoint on variable

Luc Bourhis luc_j_bourhis at mac.com
Wed Aug 25 20:39:02 MDT 2010

Hi Yann,

> I'd like to know if it's possible to have some sort of breakpoint when a variable changes.
> Let's say I have a class with a self.my_var variable, and I'd like program to stop when the code changes this variable.
> Is it something doable?

Hiding your actual variable behind a property is a nice trick to achieve what you wish for:

class your_class(object):

	def _():
		def fget(self):
			return self._my_var
		def fset(self, value):
			self._my_var = value        <<<<<<<<<<<<<<<<<<<<<
		return locals()
	my_var = property(**_())

The rest of your code does not need to be touched in any way and you would then put a breakpoint at the line marked with <<<<<<
By putting a breakpoint in the getter, you can even stop every time self.my_var has its value read by user-code.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3681 bytes
Desc: not available
Url : /pipermail/wingide-users/attachments/20100826/76fd1482/smime.bin

More information about the wingide-users mailing list