The undocumented inspect.classify_class_attrs(cls) function, along with inspect.getmro(cls) give most of the information needed to implement this feature.
By default readline displays completions alphabetically, but the function used to display completions can be replaced using ctypes or the readline module included with Python 2.6 and above. The completion_display_matches_hook function could hold a reference to the completer which would provide the last autocompleted object.
Example of problem:
In [30]: portal.<tab>
Display all 919 possibilities? (y or n)
How to override the completion_display_matches_hook in Pythons earlier than Python 2.6:
from ctypes import *
rl = cdll.LoadLibrary('libreadline.so')
def completion_display_func(matches, num_matches, max_length):
print "made you look"
The undocumented inspect. classify_ class_attrs( cls) function, along with inspect.getmro(cls) give most of the information needed to implement this feature.
By default readline displays completions alphabetically, but the function used to display completions can be replaced using ctypes or the readline module included with Python 2.6 and above. The completion_ display_ matches_ hook function could hold a reference to the completer which would provide the last autocompleted object.
Example of problem:
In [30]: portal.<tab>
Display all 919 possibilities? (y or n)
How to override the completion_ display_ matches_ hook in Pythons earlier than Python 2.6:
from ctypes import *
rl = cdll.LoadLibrar y('libreadline. so')
def completion_ display_ func(matches, num_matches, max_length):
print "made you look"
COMPLETION_ DISPLAY_ FUNC = CFUNCTYPE(None, POINTER(c_char_p), c_int, c_int) DISPLAY_ FUNC(completion _display_ func) display_ matches_ hook')
hook = COMPLETION_
ptr = c_void_p.in_dll(rl, 'rl_completion_
ptr.value = cast(hook, c_void_p).value