I have the line:
j = 99
and the below variable exists in the locals window but I cannot find the value 99 anywhere in this object; where would I need to look for that?
Ronny
Document
I have the line:
j = 99
and the below variable exists in the locals window but I cannot find the value 99 anywhere in this object; where would I need to look for that?
Ronny
Document
Oh, for that you need to understand how to inspect PyObject values. This is fairly deep and complicated stuff, so generally itâs easiest to focus on the control flow when debugging C code (e.g. watch where it branches to figure out what may be going wrong).
For some (mostly older) versions of Python, Visual Studio supports mixed-mode debugging, which knows how to do this for you and can show you the actual value. Itâs very neat how it works, but unfortunately they think that many VS users donât care about it and so it hasnât been updated for a while. I think Python 3.9 is the last version that works properly.
The problem is I need to inspect the values of complex objects, and analyzing the control flow isnât going to help me here. Rolling back to python 3.9 is also not possible due to 3rd party packages requiring newer versions of python.
Any suggestions?
Only to modify the code to either print the values that you need, or to inspect the memory manually.
I suspect you wonât, but just for completeness, you could also get the code for Visual Studioâs Python support from GitHub - microsoft/PTVS: Python Tools for Visual Studio and contribute the updates needed for mixed-mode debugging to work with newer versions.
Print statements are likely the way for you to go.
What will the PTV package provide? Will it allow me to inspect variables?
If youâre getting Python syntax highlighting and regular debugging in Visual Studio, itâs because youâve installed PTVS. Years ago it wasnât included in VS, but these days it is. Itâs still open source though, so you can contribute if you like.
Ok, thanks.