Enable tab-completion in the interactive interpreter by default
hg.python.org
hg.python.org
import readline, rlcompleter; readline.parse_and_bind("tab: complete") export PYTHONSTARTUP="$HOME/.pythonrc" readline.parse_and_bind('bind ^I rl_complete')Basically my pythonstartup.py contains the extra check for os:
AP_AUTOCOMPLETE=False
import sys
try:
import readline
except ImportError:
print "Module readline unavailable"
else:
import rlcompleter
readline.parse_and_bind("tab: complete")
if sys.platform == 'darwin':
readline.parse_and_bind("bind ^I rl_complete")
AP_AUTOCOMPLETE=True 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)Good work
But agreed, good work... tab completion is very helpful when learning a language.
Bpython is perfect for me.
In a console, I like bpython's interface and autocomplete suggestion interface, but being unable to scroll back and see what I did 3 commands ago was a deal killer.
* awareness
* the official interpreter works quite well already
* yet-another-tool to learn
I dunno, is there a better way, maybe installing iPython globally, but rewriting the shebang line to use /usr/bin/env python?
It isn't limited to packages in the virtualenv - that is, it always behaves like you created the virtualenv with system-site-packages enabled, because it is importing its own modules from there. But for most interactive use, that's not a problem.
Edit: I meant that PyPy isn't compatible with most of the things people use IPython for, like Numpy and Scipy, not that IPython's shell doesn't work on PyPy. Sorry.
Everyone is talking about reasons why using iPython can be impractical, or cumbersome/not-possible to install, but the important thing is that the default experience should strive to be the best experience.
Python has a pretty good standard library, and a pretty good batteries-included toolset, but talk to anyone who's experienced in it and you'll hear about all the Best Tools you have to install in order to be up to par: pip, virtualenv, ipython, third-party libraries to supplement what you want to do (requests, *-parse...).
When the community agrees that there are certain extras that are all good to install, it shows that the features they offer should probably be provided by default. I like Python, and I want Python to provide the best experience by default.
* pip (sort of): http://www.python.org/dev/peps/pep-0439/
* virtualenv: already in Python 3.3
* requests: http://kushaldas.in/posts/notes-from-language-summit-at-pyco...
As for IPython, many would agree it's not suitable for inclusion, which is not necessarily a bad thing. That does not stop anyone from stealing some of its features for inclusion in the default interactive interpreter though.
On Windows it's even worse, newbies have to figure out how to get it in their path and hunt-down important libraries.
good work
That's even for backport to 3.3. As for 2.7, even when when allowed, most changes aren't backported to it simply because the code has diverged a lot and core devs are tired of implementing changes twice.