rlcompleter not calling __getattr__ on [ ]

Fernando Pérez fperez528 at yahoo.com
Mon Apr 22 18:49:56 EDT 2002


holger krekel wrote:

> On Mon, Apr 22, 2002 at 11:39:24AM -0600, Fernando P?rez wrote:
>> Jaco Schieke wrote:
>> 
>> > Looks like the regexp in rlcompleter that searches the string does not
>> > work correctly.  After changing the line
>> > 
>> >> m = re.match(r"(\w+(\.\w+)*)\.(\w*)", text)
>> > 
>> > to
>> > 
>> >> m = re.match(r"([\w\[\]]+(\.[\w\[\]]+)*)\.(\w*)", text)
> 
> or maybe even r"(\S+(\.\w+)*)\.(\w*)" ? This would principally
> allow to add
> 
> "".<tab>
> 
> to work as expected. Of course you need to remove " and '
> from the delimiter list.
> 
> But then again, i wonder if the rlcompleter should not simply
> see the *whole* string and do the string-split according to delimiters
> itself? This might be more flexible for 'general purpose' completion.
> I consider the delimiters to be a rlcompleter property and
> not a readline property.

Well, your new regexp suggestion works great for me. You may want to repost 
this to python-dev or as a patch to SF, so that the powers-that-be have a say 
on the issue. For the time being, I'm using your regexp in my patched version 
of rlcompleter and running the following code:

delims = readline.get_completer_delims()
del_chars = "-/[]\"'" 
readline.set_completer_delims(delims.translate(string._idmap,del_chars))

This seems to work beautifully in all cases, completing attributes for things 
like 'hi', mylist[0] and even nested directory structures (b/c of the '/'). 
So thanks for the ideas! I'd like to see this incorporated in the standard 
rlcompleter code, as I don't see any problems caused by this (I may well be 
wrong though :)

Cheers,

f.



More information about the Python-list mailing list