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?
Asked
Active
Viewed 2,283 times
1 Answers
7
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.

David Raznick
- 17,907
- 2
- 35
- 27
-
Thanks. But you forgot to return the output of raw_input ;) – lostgeek Jul 30 '09 at 10:48
-
1Just note that if the history file is empty and the user doesn't type anything and just hits enter the code would fail. It's better to only call `readline.remove_history_item` if there was any `input` from the user – mpcabd Apr 03 '15 at 15:24