0

Is there a way to check if there is anything entered in the shell without using raw_input?

For example instead of having something like question = raw_input("Enter Q to quit") I just want to read if anything is entered into the shell, "Q" and quit.

The reason I need this is because I don't want to block my program from executing with the raw_input. I need it to periodically check at any given point if "Q" is entered at all.

FreeStyle4
  • 272
  • 6
  • 17

1 Answers1

0

Something like this might work

import sys
data_input = sys.stdin.readlines()
print "Counted", len(data_input), "lines."
Maddy
  • 2,025
  • 5
  • 26
  • 59