def setcbreak(fd, when=TCSAFLUSH):
 mode = tcgetattr(fd)
 mode[LFLAG] = (mode[LFLAG] & (~ (ECHO | ICANON)))
 mode[CC][VMIN] = 1
 mode[CC][VTIME] = 0
 tcsetattr(fd, when, mode)

def setcbreak ( fd , when = TCSAFLUSH ) : mode = tcgetattr ( fd ) mode [ LFLAG ] = ( mode [ LFLAG ] & ( ~ ( ECHO | ICANON ) ) ) mode [ CC ] [ VMIN ] = 1 mode [ CC ] [ VTIME ] = 0 tcsetattr ( fd , when , mode )
put terminal into a cbreak mode .