[IPython-dev] greedy completer breaks useful completions - fixable?

Zachary Pincus zachary.pincus at yale.edu
Mon Apr 2 17:46:09 EDT 2012


Hi all,

The normal ipython tab-completer is pretty useful in that one can do things like:
a(b.[TAB]
to get a list of b's attributes while writing out the function call. Similarly,
open('./[TAB]
will list the documents in the cwd. 

However, after enabling the "greedy completer", very useful in its own right, this behavior goes away. e.g.
a(b.[TAB]
gives nothing.

This comes down to the difference between DELIMS and GREEDY_DELIMS in IPython/core/completer.py:183.

Is there any way that the greedy completer could have a larger set of delimiters? Though, in some sense the current GREEDY_DELIMS is already too large a set, as it includes the space char, which causes the following problems:
def a(b,c): return b+c
a('a','b').[TAB] # works
a('a', 'b').[TAB] # doesn't work -- the space breaks the completer.

Is there any to make the greedy completer to be a bit smarter without it having to be a full python parser? Maybe some logic  about what to do with balanced vs. unbalanced parens/braces might be appropriate? This sort of thing would fix both of the problems above.

If people agree this is feasible, I could look into a patch, but I'm curious if anyone's tried/failed at this before...

Thanks,
Zach


More information about the IPython-dev mailing list