[IPython-dev] function specific tab completion via annotations

Brian Granger ellisonbg@gmail....
Tue Dec 18 01:51:29 CST 2012


This looks really great.  Have you tested it with the notebook yet?  I
would imagine that it should already work there as well.

On Mon, Dec 17, 2012 at 11:27 PM, Robert McGibbon <rmcgibbo@gmail.com> wrote:
> 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
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu and ellisonbg@gmail.com


More information about the IPython-dev mailing list