Auto-completion: why not module name?

Ian Kelly ian.g.kelly at gmail.com
Mon Mar 16 12:57:20 EDT 2015


On Mon, Mar 16, 2015 at 10:40 AM, Chris Angelico <rosuav at gmail.com> wrote:
> Looks to me like it's just doing the normal tab-completion of globals,
> rather than having a special case for the 'import' statement. So what
> you're talking about here is a feature request:
>
> When the input begins "import ", please can tab-completion enumerate
> available modules?
>
> This is a very plausible feature request, but be aware that it will
> involve a very costly disk search. Figuring out what modules could be
> imported means going through the entire Python module search path,
> enumerating .py (and other) files, and that could be a lot slower than
> you think.

Completeness would also be an issue. There is no general requirement
that module finders use the file system at all (one could write a
finder and loader to import modules from the network, for instance),
nor is there any API for enumerating the modules available.

Another difficulty would be packages. You can't generally know whether
foo.bar is a module until you've already imported foo.



More information about the Python-list mailing list