pexpect equivalent of Expect's “send_user”

前端 未结 2 1689
无人共我
无人共我 2021-01-23 23:57

As a continuation from my previous question on building interactive option menus in pexpect, print statements within an interact input filter do not get sent to stdout until aft

2条回答
  •  孤独总比滥情好
    2021-01-24 00:26

    Don't really know why print()'ed data is not automatically flushed when interacting with the spawned child but you can flush it explicitly so it would show up realtime:

    print('something')
    sys.stdout.flush()
    

    or just use (only for python3)

    # .raw is not buffered
    sys.stdout.buffer.raw.write('something')
    

提交回复
热议问题