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

Darren Dale dsdale24@gmail....
Tue Feb 3 11:56:14 CST 2009

On Tue, Feb 3, 2009 at 9:03 AM, Darren Dale <dsdale24@gmail.com> wrote:

> On Mon, Feb 2, 2009 at 4:06 PM, Darren Dale <dsdale24@gmail.com> wrote:
>> On Mon, Feb 2, 2009 at 8:07 AM, Ville M. Vainio <vivainio@gmail.com>wrote:
>>> On Sun, Feb 1, 2009 at 2:13 AM, Darren Dale <dsdale24@gmail.com> wrote:
>>> > Thank you for the advice. I've been looking at this most of the day,
>>> and I
>>> > think I'm stuck. I have an object I'm trying to navigate:
>>> > It's not clear to me how I would get the object at level_3 and then
>>> hook
>>> > into ipython's usual completion chain to filter attributes with leading
>>> > underscores, or the traits completer, for example. Is this possible?
>>> You just need to eval the whole thing, and see what attributes that
>>> eval'ed object has. That's what I did in ipy_greedycompleter. It's
>>> sort of "complete at your own risk" scheme, but it's the best thing
>>> you can get without putting in lots of work (and it will do what you
>>> want anyhow). The only work you need to do is determine how much you
>>> need to eval (here, it's everything before period).
>> Thanks for the suggestion. Once I determine how much to eval, do you know
>> if it is possible to hook back into the standard completer pipeline to
>> benefit from things like ipy_traits_completer?
> I'd like to make a suggestion for the regular expression in the greedy
> completer. Prepending  r"(?:.*\=+)?" should allow you to do things like:
> a=b=''.att<tab>
> since it won't include a=b= in the match.
> I'm making progress on a custom completer for a dict-like object that
> doesnt call arbitrary functions (regular expressions are a pain to relearn,
> but they are incredibly useful). I'll share what I have as soon as I tie
> what I have together.

I am nearly finished with this project, I'm just having trouble evaluating
doing the following:





I'd like it to yield


but thats a minor point. A major sticking point is:


That doesnt yield anything, but I know that a list of possible completions
is being generated, I can print the list in my completer, but its not
propagating back to ipython for some reason. Could someone please have a
look? Its easy to try it, just drop it in your ~/.ipython directory and add
this to ~/.ipython/ipy_user_conf.main:

from ipy_h5py_completer import activate

I know it says h5py, but it works on plain old dictionaries for now.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ipython.scipy.org/pipermail/ipython-dev/attachments/20090203/3583acca/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipy_h5py_completer.py
Type: text/x-python
Size: 3206 bytes
Desc: not available
Url : http://lists.ipython.scipy.org/pipermail/ipython-dev/attachments/20090203/3583acca/attachment.py 

More information about the IPython-dev mailing list