一个 IO 交互调试器

· · 个人记录

from subprocess import PIPE, Popen
from sys import argv

p1 = Popen(argv[2], stdin = PIPE, stdout = PIPE, text = True, universal_newlines = True)
p2 = Popen(argv[1], stdin = p1.stdout, stdout = p1.stdin, text = True, universal_newlines = True)

p1.wait()
p2.wait()

保存为 interactor.py,使用的时候直接 interactor.py <grader_name> <contestant_name> 即可。

需要 grader 在错误流/文件里面输出交互结果。