Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

python - raw_input without leaving a history in readline

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...