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
IDLE: Add import statement completion #61440
Comments
[patch under development] Also, if one types imp.<tab> , IDLE should import the module and list dir(module). |
Making a list of all possible modules is harder than a list of attributes. With relative imports, I am not sure its even possible to sensible make a list of every entry that would work. |
I have a patch ready; have to make it ready (PEP-8-compliance etc.) and then On 16 June 2013 00:52, Terry J. Reedy <report@bugs.python.org> wrote:
|
Even if your patch isn’t quite ready, it may (have been) better than nothing :) I had the idea to share stuff between Idle completion and Readline completion, but after looking at the Idle code, it did not seem very practical in general. But maybe you can at least use some ideas, test cases, or share the low level code from bpo-25419. E.g. my patch there has method _import_matches() that takes a path of packages and yields (sub)module names, and method _from_import_matches() that also yields module attribute names. |
I change 'enhance' to 'add' because there is no 'import completion' now. Ramchandra, when replying by email, delete the quoted email. But do submit a patch even is less than perfect. The idea of autoimporting a name to complete an attribute is separate from the idea of doing something special in import statements. Autoimport is the subject of bpo-18766, which has a patch and my thoughts so far. So this issue is only about import statements. Martin, I just opened bpo-27609 as an umbrella issue for multiple completion issues. I am not happy with the current IDLE completion code. Does any of the readline completion code depend on function provided by readline, or is it all an extension of readline, using logic in Python? |
The readline completion code does not strictly depend on on Readline, although currently it is modelled after its quirky API. But we can change that by adding a more general API. In <https://bugs.python.org/issue25419#msg266320\>, I suggested an API “complete_code(code) -> list of modules, attributes, globals, etc.” In the Readline case, you pass in the line of code up to the cursor, and it would return possible completions. Perhaps Idle might pass in multiple lines of code. There could also be a predefined global namespace, either as another parameter, or preloaded into a completer object. When I briefly looked at the Idle code a while back, it did not seem easy for me to adapt to this sort of API. But maybe you have a better idea of what could be done. |
+1 for import completion. Above, I misspelled 'rlcompleter' as 'rlcomplete'. When I just tried to import it as part of responding to bpo-41230, the wrong name did not work. I wish I could have stopped with 'import rl'<tab>. To add a note to bpo-37765, I tried 'import keywords'. Nope, no 's'. 'import ke'<tab> would have been nice. I suspect that some beginners have as much trouble with names they have no recently used. im<tab> would work if keywords were added to the tab completion list. bpo-37765. |
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: