I have this code:
def getch(self):
if os.name == 'posix':
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(fd)
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
elif os.name == 'nt':
ch = msvcrt.getch()
return ch
This runs just fine on python 2.6 and 2.7 but whenever I try and test it on python 3.0 and up there is a new line printed out by the stdin.read call, I think this may because the python 3 changes to sys.stdin, stdout, and stderr but I'm not sure how to fix it
EDIT: running on OS X 10.6.4 python 3.1 and Ubuntu 9.04 python 2.6 this happened for me.