On 7/31/2014 6:41 AM, Steven D'Aprano wrote:

I'm working on tab completion for module names. I have some alpha-quality
code working, so if I hit TAB after typing "import ma" I get this:


py> import ma
macpath      macurl2path  mailbox      mailcap      mangle
markupbase   math

This is an interesting idea for Idle. Idle currently completes names from builtins and, in interactive mode, the current globals. So in the situation above, Idle offers 'map' and 'max' in a listbox with all builtins (and globals). But after '.', it completes attribute names instead and within strings, filenames, starting from the current directory of the user process for relative names.

It should not be too hard to recognize 'import' and 'from' instead of or in addition to '.' as context markers. Even just offering stdlib name (or current directory names or . imports) would be a help. Builtin names can never be correct in this context.

For what it's worth, importing "mangle" fails with a SyntaxError. But
that's okay, I don't expect tab completion to only show *valid*
modules :-)

Over the next few days I'll make an official announcement, but if anyone
wants a sneak-peek, check out:

http://code.google.com/p/tabhistory/source/browse/tabhistory.py


where I have indenting, code completion, filename completion, and module
completion all working to some degree or another.

Thanks to everyone for their help.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to