[IPython-dev] looking for advice on a custom dict-like completer

Fernando Perez fperez.net at gmail.com
Sat Jan 31 12:34:15 EST 2009

Hey Darren,

On Sat, Jan 31, 2009 at 6:37 AM, Darren Dale <dsdale24 at gmail.com> wrote:
> Hi Fernando,
> I'm sorry to bother you. I posted not too long ago hoping to find some
> advice on how to implement a custom completer for __getitem__ access of
> dict-like objects in the h5py project, but I didnt get any responses. I
> looked through the changelogs and the commit logs, trying to identify when
> this type of completion was supported in IPython, but came up empty.

No worries, it's no bother at all.  It's my fault that I've been
mostly MIA recently on pretty much all public mailing lists,  I've
just been swamped with real life/work things.  But I'm trying to
recover a bit now :)  I've cc'd the user list so this reply is
actually archived.

> If (and only if) you have time, would you be able to provide some advice or
> direct me to some code in an old version of IPython so I could see how it
> was originally done?

I did a bit of archaeological digging, and found that 0.4 has what you want:

maqroll[scripts]> python2.4 ipython
Python 2.4.5 (#2, Aug  1 2008, 02:20:59)
Type "copyright", "credits" or "license" for more information.

IPython 0.4.0 -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
@magic  -> Information about IPython's 'magic' @ functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: a={'key':'value'}

In [2]: a['key']
Out[2]: 'value'

In [3]: a['key'].r<<TAB HERE>>
a['key'].replace  a['key'].rindex   a['key'].rsplit
a['key'].rfind    a['key'].rjust    a['key'].rstrip

Note that you'll need to run it as I did above, with python2.4,
because at the time we didn't declare the encoding of the files and
python2.5 considers that an error (my name has an accent in unicode).
You can find ipython 0.4 here, along with a bunch of other old
versions in that directory:


I'd start by looking at FlexCompleter.py in there, though there may be
a bit more elsewhere.  I hope this helps, do let me know if you need
anything else.



More information about the IPython-dev mailing list