I'm running python 2.7 on 64-bit Windows 7.
Here is the code i'm executing:
import sys
while True:
print 'please enter a character:'
c = sys.stdin.read(1)
print 'you entered', str(c)
In the PyDev evironment in eclipse I get the following output for input a and then b.
please enter a character:
a
you entered a
please enter a character:
you entered
please enter a character:
you entered
please enter a character:
b
you entered b
please enter a character:
you entered
please enter a character:
you entered
please enter a character:
It correctly gets input once and then executes twice skipping user input.
Now when I run the same code in the python terminal for input a and b I get the following output:
enter char
a
you entered a
enter char
you entered
enter char
b
you entered b
enter char
you entered
enter char
This executes once getting user input and once skipping user input.
What would be causing this issue? How do I get Python to read one char at a time in an infinite loop?