[IPython-dev] function specific tab completion via annotations
Robert McGibbon
rmcgibbo at gmail.com
Tue Dec 18 02:27:35 EST 2012
Hey,
I just posted a new PR for annotation based custom tab completion. https://github.com/ipython/ipython/pull/2701
The code is fairly complex (~1000 new lines), so I assume that there are bugs. For that reason (and because its fun!), I encourage people
to try taking it out for a spin.
It lets you do things like this:
In [1]: from IPython.extensions.completion import tab_complete, globs_to, literal
In [2]: @tab_complete
...: def baz(x) -> str:
...: pass
...:
In [3]: baz(notevaluated).<TAB>
.capitalize .find .isspace .partition .rstrip .translate
.center .format .istitle .replace .split .upper
.count .index .isupper .rfind .splitlines .zfill
.decode .isalnum .join .rindex .startswith
.encode .isalpha .ljust .rjust .strip
.endswith .isdigit .lower .rpartition .swapcase
.expandtabs .islower .lstrip .rsplit .title
And this:
In [4]: @tab_complete
...: def foo(x : globs_to('*.txt'), mode : literal('r', 'w')):
...: pass
...:
In [5]: foo(<TAB>
'COPYING.txt' 'dist/' 'setupext/'
'IPython/' 'docs/' 'tools/'
'__pycache__/' 'ipython.egg-info/'
'build/' 'scripts/'
In[6]: foo('COPYING.txt', <TAB>
'r', 'w'
-Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20121217/31e1e3b3/attachment.html>
More information about the IPython-dev
mailing list