Home > database >  Python3 shell prints ^H on pressing backspace key on Linux
Python3 shell prints ^H on pressing backspace key on Linux

Time:07-15

On python3 shell launched on bash misbehaves on pressing arrows or backspace.
It prints ^H for backspace, and I can remove these characters using Ctrl backspace or shift backspace.
But I don't want to do this workaround for backspace (I can do, but I can't ask all my users to follow),
So how to address this issue?.
BTW, I don't see this issue in python2 shell.
OS: 5.4.40-OpenNetworkLinux

python3
Python 3.8.10 (main, Jul 13 2022, 06:53:48)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.systemm^H^H^H

CodePudding user response:

Try stty erase ^H. If you regret, just use stty erase ^?. If you don't want to do this every time, put stty erase ^H into .bash_profile.

  • Related