raw_input (prompt_string)
can prompt to input. How to offer
default value? And how to make the default value user
editable?
Asked
Active
Viewed 1.1k times
2

Andrew_1510
- 12,258
- 9
- 51
- 52
-
2Probable duplicate: http://stackoverflow.com/questions/2533120/show-default-value-for-editing-on-python-input-possible – alan Apr 06 '12 at 13:57
-
That duplicate and the other answer raises an issue: are you on Windows or a Unix-like platform? – agf Apr 06 '12 at 14:01
2 Answers
8
I suggest looking into readline / pyreadline, or even possibly curses.

John Paulett
- 15,596
- 4
- 45
- 38
5
I'm not sure what you mean by user editable. If you want to provide a default they can override:
my_input = 'default value'
# user_input will be set to my_input if they just press enter
user_input = raw_input("Enter a string (default: %s):\n" % my_input) or my_input
If you want them to be able to set the default value, you either need to use two prompts -- one to set the default, and then another as above -- or else use a tool other than raw_input
.

agf
- 171,228
- 44
- 289
- 238