I'm debugging a long source code file that takes many inputs from the keyboard. I want to step through the program to see variable values, but I can't get the Python IDLE debugger to take standard input.
I'm aware I can have my source code read a file with the inputs, but I do not want to replace all my input calls with line reads. Can I have the IDLE debugger read standard input while a program is running?
Yes. The following worked for me on Win10 with 3.12.0b2. Use the [over] button on the debug window to step over the IDLE wrappers for input
and print
. When the input prompt, here ?
, appears, click on Shell to make it the active window so keypresses are detected and displayed. Hit Return
as usual to end input and return control to your program.
>>> [DEBUG ON]
>>> while True:
... s = input('? ')
... print(s)
...
? ttt
ttt
? rrrrr
rrrrr