Reputation: 79
I want to reposition the text cursor in an python input() prompt
msg = input()
print(msg)
When the user presses the left or right arrow key, the text cursor should be repositioned left or right respectively. This is to allow the user to edit the previously entered text.
Instead the arrow key values are printed ^[[D
, ^[[C
etc.
Upvotes: 6
Views: 1158
Reputation: 445
Do this (importing readline will allow you to use the arrows) :
import readline
msg = input()
print(msg)
Upvotes: 9