raw_input
is not like a web form. The name should give it away: all the function does is accept raw input (in the form of a string), optionally printing a prompt first. If you want a default value, you'll need to set it yourself as in Elizion's answer.
Now, that said, you can hack the input prompt to look sort of like what you want. I do not recommend this at all, but for the sake of completeness, give the code below a try in an interactive console:
default_val = 'default'
i = raw_input('Input val: {}\rInput val: '.format(default_val)) or default_val
Here I'm abusing the \r
character to move the cursor back to the start of the prompt. Then I re-write the actual prompt part, leaving the cursor on the d
character, so that the user can type "over" it.
You'll notice though that "default"
is still displayed there until you've typed over all of it (at which point it's probably gone for good, depending on your console's behavior). But it's only displayed; not actually part of the input. If the user enters "foo"
(which will make the prompt look like this: Input val: fooult
), i
will get the value of "foo"
. If the user just presses Enter without entering text, i
will be the empty string, which is why the or default_val
is still necessary in the code. All this is to say that this is almost certainly not what you want to do. If you want a web form, make a web form. raw_input
(and for that matter, console I/O) was not made for this.