1
0
forked from VimPlug/jedi

Merge pull request #289 from asmeurer/pythonrc

Some fixes to the .pythonrc.py code
This commit is contained in:
David Halter
2013-08-10 10:37:32 -07:00

View File

@@ -14,13 +14,39 @@ def setup_readline():
This function setups :mod:`readline` to use Jedi in Python interactive
shell. If you want to use a custom ``PYTHONSTARTUP`` file (typically
``$HOME/.pythonrc.py``), you can add this piece of code:
``$HOME/.pythonrc.py``), you can add this piece of code::
>>> try:
... from jedi.utils import setup_readline
... setup_readline()
... except ImportError:
... print('Install Jedi with pip! No autocompletion otherwise.')
try:
from jedi.utils import setup_readline
setup_readline()
except ImportError:
# Fallback to the stdlib readline completer if it is installed.
# Taken from http://docs.python.org/2/library/rlcompleter.html
print("Jedi is not installed, falling back to readline")
try:
import readline
import rlcompleter
readline.parse_and_bind("tab: complete")
except ImportError:
print("Readline is not installed either. No tab completion is enabled.")
This will fallback to the readline completer if Jedi is not installed.
The readline completer will only complete names in the global namespace,
so for example,
>>> ran<TAB> # doctest: +SKIP
will complete to ``range``
with both Jedi and readline, but
>>> range(10).cou<TAB> # doctest: +SKIP
will show complete to ``range(10).count`` only with Jedi.
You'll also need to add ``export PYTHONSTARTUP=$HOME/.pythonrc.py`` to
your shell profile (usually ``.bash_profile`` or ``.profile`` if you use
bash).
"""
try: