Skip to content

Instantly share code, notes, and snippets.

@chausen
Last active March 24, 2021 02:56
Show Gist options
  • Save chausen/56bc7b8cacaa34165c6ed387ce46b910 to your computer and use it in GitHub Desktop.
Save chausen/56bc7b8cacaa34165c6ed387ce46b910 to your computer and use it in GitHub Desktop.
Using pdb to debug a python file when using input redirection
import sys
s = input()
# pdb uses stdin to be interactive; this switches stdin to be the teletype interface
# (terminal and keyboard) after getting the redirected input
sys.stdin = open("/dev/tty")
breakpoint()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment