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

Kenneth Arnold kenneth.arnold@gmail....
Mon Aug 3 18:28:40 CDT 2009

On Mon, Aug 3, 2009 at 6:20 PM, Fernando Perez<fperez.net@gmail.com> wrote:
> On Mon, Aug 3, 2009 at 3:07 PM, Kenneth Arnold<kenneth.arnold@gmail.com> wrote:
> 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.

What if there was another keybinding that meant, "I know what I'm
doing; try harder to complete"? That way TAB can continue being an
automatic reflex and basically safe, but you don't give yourself RSI
typing things like dict keys.

(in the latter case, a cache of evaluated items (as strings) to
results could avoid double-calling in cases where that has undesirable
side-effects. Could even take over the final evaluation step to use
the cached results. Invalidate the cache whenever the input line is
cleared. There may even possibly be a way to implement this that isn't
really hairy and bug-prone. Maybe.)

> 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...

Here's a probably bad idea:

object.__getattribute__(obj, '___completable_attributes___')()
object.__getattribute__(obj, '___completable_items___')()

and a set of hooks to define those methods in the case where you can't
modify obj.__class__?


More information about the IPython-user mailing list