raw_input without leaving a history in readline

梦想的初衷 提交于 2019-11-28 08:22:39

问题


Is there a way of using raw_input without leaving a sign in the readline history, so that it don't show when tab-completing?


回答1:


You could make a function something like

import readline

def raw_input_no_history():
    input = raw_input()
    readline.remove_history_item(readline.get_current_history_length()-1)
    return input

and call that function instead of raw_input. You may not need the minus 1 dependent on where you call it from.



来源:https://stackoverflow.com/questions/1202127/raw-input-without-leaving-a-history-in-readline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!