[IPython-dev] Tab-completion of data/properties and win32com fix for IPython

Jaco Schieke ipython at ml.schieke.net
Mon Aug 2 19:00:59 EDT 2004

I had some issues trying to get tab-completion working with COM objects' 
properties in Window$ using the win32com module & IPython and have been 
able to get things working with help from the python-win32 list.  I'm 
reposting the solution on here for inclusion if it makes sense into 
IPython.  The best place to fix this would however be in python's 
rlcompleter.py and not IPython's FlexCompleter.py, but previous requests 
to fix rlcompleter.py have gone unheeded - and this one's got an even 
lower chance as it is win32 specific.

(Patch follows at the end of email)


Jaco Schieke

Thread from python-win32 follows:
-------- Original Message --------
Subject: 	Re: [python-win32] Tab-completion of data/properties and win32com
Date: 	Tue, 03 Aug 2004 00:37:49 +0200




Mark Hammond wrote:

>>I am trying to use IPython interactively to do some win32com
>>and want to use the completion feature.  The problem is that
>>tab-completion only completes the object methods, and not the
>>properties, for instance:
>IDLE doesn't have special knowledge of COM objects.  Pythonwin does though -
>it shows the Excel properties in that example.
>You could try and find the place in IDLE where the list is built, and copy
>the code from pywin\scintilla\view.py - look for the comment "# The object
>may be a COM object with typelib support - lets see if we can get its
>props."  Then submit a patch for IDLE, and it may well be accepted.
>Another cute idea would be to hack makepy to use "properties" for 2.3 and
>later - this should make them look more "real" - but IDLE may not support
>that yet (and it would be non-trivial anyway)

Thanks for the advice.  We misunderstood each other, but I got it 
working.  What I ended up doing is to patch rlcompleter.py to allow it 
to get all the attributes of the COM object (as is done in pywin's 
view.py).  I'm currently using IPython (ipython.scipy.org) which is 
using a modified rlcompleter.py due to limitations of the exising 
rlcompleter.py implementation.  I'll submit a patch to IPython and see 
if it gets accepted there.

Would there be any point in submitting a patch against 2.3's 
rlcompleter?  This is a win32 specific feature, and if I understand you 
correctly, it can be solved in other ways by fixing makepy.

Regards & tx for the assistance,


Index: ipython/IPython/FlexCompleter.py
RCS file: /home/cvsroot/world/ipython/IPython/FlexCompleter.py,v
retrieving revision 1.3
diff -r1.3 FlexCompleter.py
>         def list2dict(l):
>             ret={}
>             for i in l:
> 	        ret[i] = None
>             return ret
>         matches_dict = {}
>         matches_dict.update(list2dict(matches))
>         matches = matches_dict.keys()
>         matches.sort()
>     try:
>         ret=ret+klass._prop_map_get_.keys()
>         ret=ret+klass._prop_map_put_.keys()
>         pass
>     except AttributeError:
>         pass

More information about the IPython-dev mailing list