How do you see the entire command history in interactive Python?

后端 未结 10 1796
不知归路
不知归路 2020-11-30 16:36

I\'m working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow

10条回答
  •  死守一世寂寞
    2020-11-30 17:16

    This should give you the commands printed out in separate lines:

    import readline
    map(lambda p:print(readline.get_history_item(p)),
        map(lambda p:p, range(readline.get_current_history_length()))
    )
    

提交回复
热议问题