diff --git a/jedi/utils.py b/jedi/utils.py index cc5d2a41..492e2c90 100644 --- a/jedi/utils.py +++ b/jedi/utils.py @@ -20,20 +20,32 @@ def setup_readline(): from jedi.utils import setup_readline setup_readline() except ImportError: - print('Install Jedi! No autocompletion otherwise.') + # Fallback to the stdlib readline completer if it is installed. + # Taken from http://docs.python.org/2/library/rlcompleter.html + try: + import readline + import rlcompleter + readline.parse_and_bind("tab: complete") + except ImportError: + pass - Alternately, you can fall back to regular readline completion with - something like:: + 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, - try: - from jedi.utils import setup_readline - setup_readline() - except ImportError: - import readline, rlcompleter - readline.parse_and_bind("tab: complete") + >>> ran + + will complete to ``range`` + + with both Jedi and readline, but + + >>> range(10).cou + + will show complete to ``range(10).count`` only with Jedi. You'll also need to add ``export PYTHONSTARTUP=$HOME/.pythonrc.py`` to - your bash profile (usually ``.bash_profile`` or ``.profile``). + your shell profile (usually ``.bash_profile`` or ``.profile`` if you use + bash). """ try: