TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Enable tab-completion in the interactive interpreter by default

155 pointsby tshepangabout 12 years ago

12 comments

estabout 12 years ago
To use tab completion in earlier Python versions:<p><pre><code> import readline, rlcompleter; readline.parse_and_bind("tab: complete")</code></pre>
评论 #5658408 未加载
评论 #5658416 未加载
Camilloabout 12 years ago
One problem with tab completion is that you can no longer paste tab-indented snippets into the intepreter, or use tab to indent code you're typing. I put the following in my python startup file to fix the issue:<p><pre><code> import readline, rlcompleter readline.parse_and_bind("tab: complete") readline.parse_and_bind('bind ^I rl_complete') class MyCompleter(rlcompleter.Completer): def complete(self, text, state): if text.lstrip() == '': if state == 0: return text + '\t' else: return None else: return rlcompleter.Completer.complete(self, text, state) readline.set_completer(MyCompleter().complete)</code></pre>
评论 #5660929 未加载
obviouslygreenabout 12 years ago
Wow, it's about time. It's not that hard to set up tab completion using a startup script, but that always struck me as sort of a backwards thing to have to do every time I set up a new server or workstation.
ak217about 12 years ago
Tangentially related: Shell tab completion for Python programs using argparse: <a href="https://github.com/kislyuk/argcomplete" rel="nofollow">https://github.com/kislyuk/argcomplete</a>
Goranekabout 12 years ago
I always wondered why default interpreter can't be more like bpython.<p>Good work
评论 #5658281 未加载
dmdabout 12 years ago
This is great, but is there any reason whatsoever not to use ipython?
评论 #5658514 未加载
评论 #5658417 未加载
评论 #5658993 未加载
评论 #5659148 未加载
评论 #5658402 未加载
评论 #5663439 未加载
评论 #5658528 未加载
tshepangabout 12 years ago
The related Issue has been open since 2009: <a href="http://bugs.python.org/issue5845" rel="nofollow">http://bugs.python.org/issue5845</a>.
digisignabout 12 years ago
I've always wondered why so many of these usability niceties have been available yet neglected soooo long, while the language as a whole has progressed so much? There are plenty more of these, like interpreter history and adding pip to the stdlib.<p>On Windows it's even worse, newbies have to figure out how to get it in their path and hunt-down important libraries.
评论 #5660188 未加载
spicavigoabout 12 years ago
I don't remember the last time I used anything except iPython. I use EC2 a lot, and the first thing I do after firing an instance is install ipython, even if I don't intend to use the instance for python related stuff at all.
jayfluxabout 12 years ago
Antoine Pitrou has certainly contributed a lot to CPython.<p>good work
评论 #5658386 未加载
oellegaardabout 12 years ago
Will this be on 2.7.x or just 3.x?
评论 #5658490 未加载
jfbabout 12 years ago
Next up: sqlplus.
评论 #5666495 未加载
评论 #5667368 未加载