[IPython-user] IPython tab-completion behaviour in Linux

Fernando Perez fperez.net@gmail....
Mon Aug 3 17:20:34 CDT 2009


On Mon, Aug 3, 2009 at 3:07 PM, Kenneth Arnold<kenneth.arnold@gmail.com> wrote:
> On Mon, Aug 3, 2009 at 5:57 PM, Fernando Perez<fperez.net@gmail.com> wrote:
>> we look for 'foo.bar' in your namespace, but we don't do
>> eval('foo.bar') at all.  Since '{}' is not in your namespace, it isn't
>> found, and the next available completer (for files) tries to fill in.
>
> I occasionally forget something about a built-in type, so I too wish I
> could do [].<TAB>. But it's no big deal; I just type []<ENTER>, then
> _.<TAB>.
>
> Modules are also dynamically loaded if you do 'from module import
> <TAB>', which is helpful but can itself run into problems if you're
> not careful. I think there are optional completers for particular
> things that require evaluation, like dict keys, but I never got around
> to looking that up. You really need to be careful about introspection
> in dynamic environments; there are lots of possible hidden side
> effects. There's a subtle art between introspecting too much and too
> little, and I think the devs have done an overall good job at finding
> that balance.

You describe the problem very well.  I *hope* we've found a reasonable
balance, though it's unfortunately one of those problems where one day
you wish it was more aggressive, and the next that it were less,
depending on precisely what you are doing.  From having been bitten
early on by being too aggressive, I've backed off into a position that
I'd rather have something robust and reliable even if it's a little
less convenient sometimes.

One area that remains a problem (and this isn't ipython, the plain
rlcompleter.py from the stdlib does the same) is that introspecting
foo.bar for completions already triggers getattr on foo to extract
.bar, and that may already be one side effect too many for some.
Unfortunately, short of removing all dynamic introspection from
ipython, I don't think this is solvable, but I'm open to good ideas on
this problem...

>> Early in its life ipython used to eval() user input before completion,
>> and that was the source of many problems, so it has been removed.
>
> Another source of random problems in my experience is autocall. If you
> don't use it, turn it off (or learn how to use it <grin>).

Yup, very true and well timed (see my other post on print() woes) :)

Thanks!

f


More information about the IPython-user mailing list