Python Forum
readline.parse_and_bind() does not work in start-up script of Python interpreter - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: readline.parse_and_bind() does not work in start-up script of Python interpreter (/thread-36116.html)



readline.parse_and_bind() does not work in start-up script of Python interpreter - zzzhhh - Jan-18-2022

I created a startup script file

import readline  
readline.parse_and_bind("set disable-completion on")  
readline.parse_and_bind("tab: self-insert")
and point environment variable PYTHONSTARTUP to it. The effect of this start-up script is that I can type Tab key as 8 space bars in the Python interpreter command line, instead of as a command of completion. Although I'm sure this start-up script is indeed executed when Python interpreter is started, the statements are not in effect. That is, when I type Tab key, the python command line still tries to complete and utters a lot of error (because there is nothing to be completed). These commands take effects only if I type them in Python command line explicitly. So, is readline.parse_and_bind() function known to not work in start-up scripts? If it is supposed to be working, how can I make it work?

PS, I am using Python 3.9.5 interpreter in miniconda3 on Windows 10. I start Python interpreter by typing "python". The above start-up script file exists and the environment variable PYTHONSTARTUP is set up properly.