Reading a single character (getch style) in Python is not working in Unix -


I use the recipe at any time, I can not seem to work on it It always throws the following error:

  Traceback (last most recent call): ... old_settings = termios.tcgetattr (fd) termios.error: (22, "invalid argument)" < / Code> 

My best idea is that it is because I'm playing it in eclipse, so Termos is throwing a worthy about the file descriptor.

This is working on Ubuntu 8.04.1, Python 2.5.2, I do not have any such error Join Maybe you should try it from the command line, eclipse is using its own studine, I get exactly the same error in running with wing IDE, but this works great from the command line. The reason for this is that the IDE, for example, wing is using its class netware. Sys.stdin as CDBG intrestream therefore sys.stdin.fileno is zero, hence the error is basically why IDE stdin is not a tty (print sys.stdin.isatty () False)

  Class _GetchUnix: def __init __ (self): import tty, sys def __call __ (self): import system, tty, termios fd = sys.stdin.fileno () old_settings = termios.tcgetattr (fd) try: tty.setraw ( Sys.stdin.fileno ()) ch = sys.stdin.read (1) Finally: termios.tcsetattr (FD, TERMOS.TCSADRAN, OLD_SATINGS) Return CH Holly = _GetchUnix () Get print ()  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -