-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to break exactly when a variable changes #65
Comments
Three remarks:
|
OK, I didn't put much thought into it yet :) I just noticed that I wanted this feature today when I was trying to figure out the first time in a module that a variable became defined, and the best way I could figure out to do it was to set it as a watch expression and press To answer your questions:
I guess we should experiment with performance, but probably we should let the user customize this. It should be either
OK, I didn't know that. I'll have to think about how to implement this then.
I guess watch expressions are the wrong way to think about this. Better would be to add a new checkbox for the dialog that comes up when you press Actually, thinking about how to implement this, it would be harder to do for a watch expression--and potentially much more expensive. I think you'd have to somehow add a hook to the locals dictionary, which has a callback to PuDB if the variable changes. This may or may not work (from my understanding, the locals dictionary is not really a dictionary, so such a hook may not work. I also don't know what kinds of optimizations exist for it). Making it work for watch expressions would be trickier: the hook would have to reevaluate the watch expression each time the locals dictionary is accessed. There are also subtleties if you want to support attributes with new/old-style classes and So all in all, this is definitely a hard problem. But it might be fun to learn more about the Python internals. And I don't think there's any question that it would be a useful feature. If my locals hack doesn't work, I suppose we could have PuDB " |
locals falls short. You might want to break on a changed instance attribute... |
Looks like with code from https://github.com/cool-RR/PySnooper it is possible to cover this. |
The whole point of watch expressions is that that is the expression you are interested in. So it would be useful to be able to press
c
and have the script stop exactly when it changes. This probably should be the default (though either way, there should be an option). At least, that's what the name "watch expression" suggests to me.The text was updated successfully, but these errors were encountered: