-
Notifications
You must be signed in to change notification settings - Fork 230
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 the ability to set a watch expression on an object by ID #511
Comments
I can see the use case. I'd be happy to consider a PR. This could be done by simply storing a reference to an object instead of the name in a watch expression, maybe with a "by-name" vs "by-value" toggle in watch expression creation. |
I'm taking a look at this, and I see two potentially separate ideas here:
So, some questions:
|
Super happy you're thinking about this @mvanderkamp! I'm not a maintainer, but I can respond with my thoughts when I was writing this issue. Obviously take it or leave it: Two Separate Ideas:
Yes, I feel like this should be a toggle. Sometimes I want to watch how a variable name changes within a scope (usually because I'm watching how a number or string changes in response to operations), and sometimes I want to observe how different scopes mutate a value (often a mutable class or dict).
I think that this is a question about whether the watch expression should evaluate the name vs the value? If so, I think it should be a toggle as mentioned above. I might be misunderstanding here. So, some questions:
IMO they need to be distinct, because some values are immutable and so the only thing you can do is watch a variable name. Being able to watch a variable name across scopes is also interesting, but I'm most interested in watching a value as it mutates across frames.
This seems valid, although I haven't specifically wanted it. I can imagine those times where it is suprisingly useful being extremely useful (e.g. not realizing that the same variable name is used for two entirely unrelated purposes in the same stack. That has bit me at least once.)
No opinion on the implementation, but I did suggest an alternate UI flow to select an available value (not variable, e.g.
IMO this would be great, e.g.:
I don't see any specific benefit to the "preserve the error" behavior (maybe it's more comprehensible?) but I have no strong opinion. |
Thanks for the input! I think I need to clarify a bit about the "global" vs "local" distinction. Currently when you create a watch expression, it only exists for the current stack frame ("local"). If you're watching some variable by value that probably indicates that you want to continue using that same watch expression in other stack frames ("global"). So the question is: is there a need for more than one toggle? I.e. one would be "always eval the expression" vs "watch the value, don't eval again", and the other would be "show this watch expression in this stack frame only" vs "show this watch expression in all stack frames".
|
Ah, yes. I think they should be separate toggles. I can imagine (and have wanted) to just watch the same variable name across multiple stack frames. I can also imagine not wanting to watch a value across frames, even though this isn't something I specifically recall desiring. |
If you have a chance to take a look at #525 I'm curious to hear your thoughts. |
Thanks for working on this. I just returned from a trip and will be swamped for a bit, but the PR is on my radar. |
This looks very related to this issue #65 |
Is your feature request related to a problem? Please describe.
I would love to be able to trace the evolution of a value across stack frames. This means that variables don't exist, but often the object that I care about is being mutated.
Describe the solution you'd like
The nicest thing, I think, would be for the watch expression dialog to get an enhanced view (maybe a select box that changes it to be this view)
myobj________
myobj.value___
In an ideal world, pudb would look up the
id(myobj)
and then every time it entered a frame it would scan the variables to see if any of them have the same ID as myobj. If they do, then:myobj.value: ...
(myobj -> newname).value: ...
myobj: <missing>
Describe alternatives you've considered
Currently I just constantly re-enter watch expressions in every frame, whether or not the variable name has changed.
Having the option to have watch expressions persist across frames would be helpful, usually there is a set of at most 4 var names that I care about and I wouldn't mind having 3 of the 4 be an error at any given time if it meant I didn't need to re-enter expressions all the time.
The text was updated successfully, but these errors were encountered: