def setraw(fd, when=TCSAFLUSH):
 mode = tcgetattr(fd)
 mode[IFLAG] = (mode[IFLAG] & (~ ((((BRKINT | ICRNL) | INPCK) | ISTRIP) | IXON)))
 mode[OFLAG] = (mode[OFLAG] & (~ OPOST))
 mode[CFLAG] = (mode[CFLAG] & (~ (CSIZE | PARENB)))
 mode[CFLAG] = (mode[CFLAG] | CS8)
 mode[LFLAG] = (mode[LFLAG] & (~ (((ECHO | ICANON) | IEXTEN) | ISIG)))
 mode[CC][VMIN] = 1
 mode[CC][VTIME] = 0
 tcsetattr(fd, when, mode)

def setraw ( fd , when = TCSAFLUSH ) : mode = tcgetattr ( fd ) mode [ IFLAG ] = ( mode [ IFLAG ] & ( ~ ( ( ( ( BRKINT | ICRNL ) | INPCK ) | ISTRIP ) | IXON ) ) ) mode [ OFLAG ] = ( mode [ OFLAG ] & ( ~ OPOST ) ) mode [ CFLAG ] = ( mode [ CFLAG ] & ( ~ ( CSIZE | PARENB ) ) ) mode [ CFLAG ] = ( mode [ CFLAG ] | CS8 ) mode [ LFLAG ] = ( mode [ LFLAG ] & ( ~ ( ( ( ECHO | ICANON ) | IEXTEN ) | ISIG ) ) ) mode [ CC ] [ VMIN ] = 1 mode [ CC ] [ VTIME ] = 0 tcsetattr ( fd , when , mode )
put terminal into a raw mode .