Search code examples
pythonraw-input

Allowing users to delete user input in python


This is a pretty basic question I'm having trouble with. I have a python program, and when I use raw_input to get user input, whenever I try to delete something the user already types, this symbol appears: ^H, instead of allowing me to delete what I have already typed. How can I allow users to delete previous things they've typed?


Solution

  • If you import the readline module, raw_input() should use it with no further modification, and you'll get better control sequence support.

    More info: http://docs.python.org/2/library/readline.html