Code follows: -------- # test.py a simulated chess engine import sys # chess engine main processing loop: while True: # get player's move from GUI: playerMove = sys.stdin.readline().strip('\n') # process command: if playerMove == 'e4': engineMove = 'e5' elif playerMove == 'd4': engineMove = 'd5' else: engineMove = 'Unknown move!' # send the engine response move back: sys.stdout.write("%s\n" % engineMove) # the following seems required: sys.stdout.flush()