Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87635

Re: Auto-completion: why not module name?

References <18705a55-6b0a-4b55-99ab-479c19566e1a@googlegroups.com> <5507e181$0$11104$c3e8da3@news.astraweb.com>
From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date 2015-03-17 12:22 +0000
Subject Re: Auto-completion: why not module name?
Newsgroups comp.lang.python
Message-ID <mailman.494.1426594982.21433.python-list@python.org> (permalink)

Show all headers | View raw


On 17 March 2015 at 08:10, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Tuesday 17 March 2015 03:23, candide wrote:
>
> You might like my tab completion and command history module:
>
> http://code.google.com/p/tabhistory/
>
> I've been using it on Linux for about three or four years, and although I
> don't promise it is bug-free, it shouldn't blow up your computer :-)

Good work Steven. I just gave it a try and it works great.

> It supports module completion in `import` and `from ... import` statements.
> It even supports module attribute completion if the module is already
> cached.
>
> E.g. if the re module is cached, typing
>
>     from re import ma[TAB}
>
> will compete the "ma" to "match".

BTW ipython does this and goes one step further. It basically imports
the module while tab completion is ongoing so that you can complete
"from ...import" without needing to import the module first. In
principle that could be problematic but in practice I find it useful
and it has never caused me any actual problems.

> By default, the tabhistory module:
>
> * indents at the start of the line

Any reason for using 8 spaces for a tab? Or is that just my terminal
(gnome-terminal)?

> * completes on module names in `import` and `from` statements
> * completes on file names inside strings

I'm not sure what causes this but I have a symlink in my user
directory called "current" that just takes me to the things I'm
currently working on. When I tab complete it it puts in a quote
character:

>>> with open('current'

I think it thinks that "current" is a complete filename when it's
actually a symlink to a directory containing other things. If I delete
the quote and add a slash then it continues to complete normally.

Not sure if it's relevant but my .inputrc has:
set mark-symlinked-directories on

This setting changes the way that symlinks to directories are
completed so that a slash is automatically added when I tab complete
them.

> * and completes on global and builtin names and keywords everywhere else.
>
> You can read an announcement here:
>
> http://code.activestate.com/lists/python-list/672898/
>
> Feedback from Mac and Windows users is very, very welcome.

On Linux unfortunately.


Oscar

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Auto-completion: why not module name? candide <c.candide@laposte.net> - 2015-03-16 09:23 -0700
  Re: Auto-completion: why not module name? Chris Angelico <rosuav@gmail.com> - 2015-03-17 03:40 +1100
  Re: Auto-completion: why not module name? Jonas Wielicki <jonas@wielicki.name> - 2015-03-16 17:54 +0100
  Re: Auto-completion: why not module name? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-16 10:57 -0600
  Re: Auto-completion: why not module name? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-17 19:10 +1100
    Re: Auto-completion: why not module name? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2015-03-17 12:22 +0000
      Re: Auto-completion: why not module name? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-18 09:54 +1100
  Auto-completion of Unicode names [was why not module name?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-18 10:29 +1100
    Re: Auto-completion of Unicode names [was why not module name?] Chris Angelico <rosuav@gmail.com> - 2015-03-18 11:06 +1100
    Re: Auto-completion of Unicode names [was why not module name?] Dan Sommers <dan@tombstonezero.net> - 2015-03-18 01:07 +0000

csiph-web