[issue37765] IDLE: Include keywords in __main__ autocomplete list

Terry J. Reedy report at bugs.python.org
Mon Aug 5 16:16:06 EDT 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

If keywords are included when the REPL has tab completions (which Windows doesn't), then it is plausible that IDLE should.  It could be considered part of 'Shell should (mostly) imitate REPL'.  But I can see Tal's point, though the relative expansion is pretty small.  And there is nothing on the master completions issue #27609 where I collected known not-yet-rejected suggestions and ideas.

The implementation is trivial.  Add two new lines to autocomplete.py.  So you can easily patch a private copy.  I am preparing a minimal PR.

import keyword  # add
...
    def fetch_completions(self, what, mode):
...
                    bigl = eval("dir()", namespace)
                    bigl.extend(keyword.kwlist)  # add
                    bigl.sort()

True, False, and None are also in builtins, so cannot serve as a test.
---

A separate idea: annotate completion list, at least as an option, with 'keyword' or class, possibly prefixed with 'built-in', so 'built-in function', 'function', and so on.

----------
nosy:  -rhettinger
stage:  -> test needed
title: Include keywords in autocomplete list for IDLE -> IDLE: Include keywords in __main__ autocomplete list
versions: +Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37765>
_______________________________________


More information about the Python-bugs-list mailing list