Python Interpreter Auto Completion lufy October 31, 2017 <p>In linux bash, and django ./manage.py shell, double click TAB key would get auto completion. However, the default python interpreter has no such function, but fortunately, this could be added with steps next:</p> <p><span style="background-color: #888888;">vim /usr/lib/python2.7/site-packages/tab.py</span></p> <p><span style="background-color: #888888;">import readline</span><br /><span style="background-color: #888888;">import rlcompleter</span><br /><span style="background-color: #888888;">import atexit</span><br /><span style="background-color: #888888;">import os</span></p> <p><span style="background-color: #888888;">readline.parse_and_bind('tab:complete')</span></p> <p><span style="background-color: #888888;">histfile = os.path.join(os.environ['HOME'],'.pythonhistory')</span><br /><span style="background-color: #888888;">try:</span><br /><span style="background-color: #888888;"> readline.read_history_file(histfile)</span><br /><span style="background-color: #888888;">except IOError:</span><br /><span style="background-color: #888888;"> pass</span><br /><span style="background-color: #888888;">atexit.register(readline.write_history_file, histfile)</span></p> <p>Then import tab module, TAB key well be valid.</p> <p>~]# python</p> <p>Python 2.7.5</p> <p>......</p> <p>>>> import tab</p> <p>>>> ...</p>
Comments (0)
Leave a Comment
No comments yet. Be the first to comment!