New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make rlcompleter avoid duplicate global names #69849
Comments
When playing with the Editline alternative to Readline, I noticed that “global” name completions can include duplicates: >>> No
None NotADirectoryError( NotImplementedError(
None NotImplemented
>>> None
None None It completed my line to “None”, but if you hit Tab again, it lists two duplicate options both identical to what I already have. The reason is that “None” is both a reserved keyword, and a member of the builtins module. My patch avoids adding extra completions if a name has already been added. It also prioritizes the global namespace over builtins, so that say if you alias “int” to a non-callable, it is no longer listed with an opening bracket “(” suffix. Earlier behaviour: >>> int = 81
>>> in
in input( int int( Now: >>> in
in input( int |
Nice work. An alternative approach is to make "matches" a dict. And instead of if match not in seen:
seen.add(word)
matches.append(match) use just
I don't know what approach is better. Added other minor comments on Rietveld. |
New changeset 4799615f4f26 by Martin Panter in branch '3.4': New changeset 4ed70c568baf by Martin Panter in branch '3.5': New changeset 96fb9daf64a5 by Martin Panter in branch 'default': New changeset f742c31491e3 by Martin Panter in branch 'default': |
New changeset d3a9b055206c by Martin Panter in branch '2.7': |
I chose to keep my strategy of using the set. Using a dictionary to hold the matches could mess up the order, although it looks like Readline sorts the matches before displaying them. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: