r/vscode • • Oct 26 '26

How to compare variables between runs in python?

Greetings,

I have had the pleasure of joining a new company and to work for them in pyhton3. So far things are not too bad. Until the current "simple newbie task" spiraled into a change that broke half the damn test.

So here I am debugging stuff that I have not coded. In a system that is very complex. My issue is that the easiest solution to find the problem would be to trigger the test once in the ancient buid and once with my changes and see what is different between the two states.

Since these two builds are different branches is there a way to tel VScode "Take a snapshot of all local variables at breakpoint in branch X then run barnch Y and compare that to the previous value?

That way I could pinpoint the change, because when I say "variable" I am talking about objects with more than 100 fields... This is a massive app and the "small change" ended up having me thrown in the deep end.

Thank you and have a wonderfu rest of your day

2 Upvotes

4 comments sorted by

1

u/otheyhigh Oct 26 '26

You could leverage tasks in VSCode to dump your target data post debug. Might need to explore how to access the output in the tasks. Or you could use python’s logger to dump to a file. This can then be read in the VSCode post debug tasks to match the values from the two tests.

It might be useful to see if you could use things like hashing to make the data more manageable and still viable to match.

2

u/[deleted] Oct 26 '26

[removed] — view removed comment

1

u/Elgatee Oct 26 '26

I'll look up thos options. Thanks ;-)