Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to view entire contents of variable in Python IDLE Debugger?

I am trying to view the entire contents of a variable in the IDLE Debugger for Python 3.6.1. The debugger gives a preview but there appears to be no way to pull all the data out from the debugger.

The only work-around I've found is to throw a print() statement in the code somewhere. Is this the only way? See picture: enter image description here

This example's decryptedText variable has over 700 characters but as we see, only a few are visible. Thanks.

like image 527
the_endian Avatar asked Sep 13 '25 22:09

the_endian


1 Answers

As the IDLE debugger is currently written, the only way to get more information about the state of an object at a particular point in the execution is to either insert print calls in the code or stop execution (raise SystemExit, for instance) and interact with the object in the Shell.

What you see in the locals/globals panels are representations of objects produced by reprlib.Repr with maxstring and maxother increased to 60. One could edit NamespaceViewer in idlelib/debugger.py (3.6 name) to increase maxstring to, say, 200 and maximize the debug window. (I verified that this works to show more of a string.) One could also try replacing the single line Entry widget with a Label widget sized to height lines and width chars and setting maxstring to height * width. (Untried.)

I agree that being able to get more information on a object would be good. I am currently thinking about a separate popup window with type, length (if appropriate), and a much bigger slice of the contents.

like image 161
Terry Jan Reedy Avatar answered Sep 15 '25 13:09

Terry Jan Reedy