def get_command(next_fall_time):       
    "if a command is entered, return it; otherwise raise the exception Timeout"
    while True:  # until a timeout occurs or a command is found:
        timeout = next_fall_time - time.time()
        if timeout > 0.0:
            (r, w, e) = select.select([ sys.stdin ], [], [], timeout)
        else:
            raise Timeout()
        if sys.stdin not in r:  # not input on stdin?
            raise Timeout()
        key = os.read(sys.stdin.fileno(), 1)
        if   key == 'j':
            return left
        elif key == 'l':
            return right
        elif key == 'k':
            return turn
        elif key == ' ':
            return down
        elif key == 'q':
            return quit
        else:  # any other key:  ignore
            pass
if a command is entered, return it; otherwise raise the exception Timeout
recipes/Python/580680_Tetris/recipe-580680.py