'How do I debug stdin in vscode using python in linux?
I am using VS Code on Ubuntu and I wrote this simple python script to read user input from the terminal, just to learn about standard input modes. I want to demonstrate the value in sys.stdin when the standard input mode is set to 'cbreak' (using tty.setcbreak(sys.stdin.fileno())).
I added sys.stdin.read(), sys.stdin.readline() and sys.stdin.readlines() to the watch variables but I am not getting anything. The variables show 'not available' and the local variables on the top left show loading.
How can I watch standard input?
Here is the script and a screenshot below.
import sys,tty,termios
old_attr=termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin.fileno())
input()
print("Exit")
termios.tcsetattr(sys.stdin,termios.TCSADRAIN,old_attr)
Solution 1:[1]
You add a breakpoint in line7.
You coulde press F5 to continue so that you can get the output in the terminal.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MingJie-MSFT |

