0

When using backspace it adds extra character in raw_input

I am using python 2.7 on Mobaxterm. I am using raw_input for the user input. For example if user wants to give an input such as "Python Language" but instead there is spelling mistake and user has to use backspace to correct the word/alphabet. At this moment there are some extra characters are added. try:

inp = raw_input("Enter a saved search name: ")
# Retrieve the new search
mysavedsearch = service.saved_searches[inp]`enter code here`

Expected Output: correct word, for example if user writes "pythin", user can use backspace and then correct it to "python"

Actual Output:

UrlEncoded('pyt\x08\x08\on')
jeffjenx
  • 17,041
  • 6
  • 57
  • 99
PyPy2304
  • 17
  • 1
  • 7
  • Why don't you use just `input`? Because `raw_input` is not interpreted in python, this is why it tracks the backspace as well – Albo Sep 06 '19 at 11:56
  • Hi @Albo, I am using Splunk SDk which is comaptible only with python 2.7 now, hence I am using 'raw_input'. I cannot use 'input' as it takes input only as integer in python 2.7. Interestingly, when I am using IDLE and using backspace I am getting correct output, is the problem related to MobaXterm? – PyPy2304 Sep 09 '19 at 06:24

0 Answers0