From cea1d265a65d2c58cc21905c436431ffe8eeb088 Mon Sep 17 00:00:00 2001 From: David Halter Date: Mon, 5 Aug 2013 15:18:24 +0430 Subject: [PATCH] repl documentation, adds @asmeurer suggestions --- docs/docs/repl.rst | 14 ++++++++++++-- jedi/replstartup.py | 2 -- jedi/utils.py | 11 +++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/docs/repl.rst b/docs/docs/repl.rst index e911e46e..b89230d9 100644 --- a/docs/docs/repl.rst +++ b/docs/docs/repl.rst @@ -1,8 +1,18 @@ .. include:: ../global.rst -How to use Jedi from Python interpreter -======================================= +Jedi autocompletion in the Python interpreter +============================================= + +There are two different options how you can use Jedi autocompletion in +your Python interpreter. One with your custom ``$HOME/.pythonrc.py`` file +and one that uses ``PYTHONSTARTUP``. + +Using ``PYTHONSTARTUP`` +----------------------- .. automodule:: jedi.replstartup +Using a custom ``$HOME/.pythonrc.py`` +------------------------------------- + .. autofunction:: jedi.utils.setup_readline diff --git a/jedi/replstartup.py b/jedi/replstartup.py index 40ee77da..828e090e 100644 --- a/jedi/replstartup.py +++ b/jedi/replstartup.py @@ -1,6 +1,4 @@ """ -``PYTHONSTARTUP`` to use Jedi in your Python interpreter. - To use Jedi completion in Python interpreter, add the following in your shell setup (e.g., ``.bashrc``):: diff --git a/jedi/utils.py b/jedi/utils.py index 37aa2225..50b0cc30 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -93,11 +93,14 @@ def setup_readline(): Install Jedi completer to :mod:`readline`. This function setups :mod:`readline` to use Jedi in Python interactive - shell. If you want to use custom ``PYTHONSTARTUP`` file, you can call - this function like this: + shell. If you want to use a custom ``PYTHONSTARTUP`` file (typically + ``$HOME/.pythonrc.py``), you can add this piece of code: - >>> from jedi.utils import setup_readline - >>> setup_readline() + >>> try: + >>> from jedi.utils import setup_readline + >>> setup_readline() + >>> except ImportError: + >>> print('Install Jedi with pip! No autocompletion otherwise.') """ try: