[Python-ideas] Open parenthesis in REPL completion

Danilo J. S. Bellini danilo.bellini at gmail.com
Sat Apr 20 13:51:34 EDT 2019


For most of the time, I'm already copying and pasting stuff from a text
editor to use its completion instead. After more than an year having
trouble with this, I think there's no way I can "get used" to it in any
positive sense, but when I stick to the REPL for a long time, I'm aware
that I press backspace all the time after TAB, sometimes unconsciously.
Typing the last char manually hurts less than breaking the bracket matching
expectation. I usually type both the open and close parentheses at once,
then I move the cursor back one character to type its contents, so I never
forget some unmatched parenthesis, but that strategy (which still works for
other brackets and almost everywhere else) gets broken when some open
parenthesis appear for some completions but not for others.

On Sat, 20 Apr 2019 at 12:57, Jonathan Fine <jfine2358 at gmail.com> wrote:

> On Unix the behaviour follows from
> https://docs.python.org/3/library/rlcompleter.html and also
> https://docs.python.org/3/library/site.html#rlcompleter-config.
>
> I read in https://docs.python.org/3/library/site.html that site.py
> attempts "to import a module named usercustomize, which can perform
> arbitrary user-specific customizations".
>

Thanks. From those links I found that this behavior is a quite old stuff
<https://bugs.python.org/issue449227>, though the completion wasn't active
by default in Python 2.7. The documentation states that only Python 3.4
activated it by default.

The solution I found from reading that code is this oneliner, which I'll
copy and paste after loading the REPL (yes, it's monkeypatching a seemingly
private method):

__import__("rlcompleter").Completer._callable_postfix = lambda self, val,
word: word

Is there a default PYTHONSTARTUP file name in Python 3.7.3, or at least a
single global configuration file for the REPL where I can put that oneliner
or a file reference with that line? I strongly prefer not to mess around
with ~/.bashrc, ~/.zshrc and scattered stuff like that, if possible.

--
Danilo J. S. Bellini
---------------
"*It is not our business to set up prohibitions, but to arrive at
conventions.*" (R. Carnap)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190420/6a5f8c89/attachment.html>


More information about the Python-ideas mailing list