467,222 Members | 1,405 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,222 developers. It's quick & easy.

Get all attributes of a com object

Without to know the names, is it possible to dump all attributes of a
com object?
from win32com.adsi import *
objDom = ADsOpenObject("LDAP:/ ...
print ???"all attributes"??? of objDom

Thanks
Wolfgang

Apr 27 '06 #1
  • viewed: 5782
Share:
5 Replies
eicwo01 wrote:
Without to know the names, is it possible to dump all attributes of a
com object?
from win32com.adsi import *
<ot>
from module import * is Bad(tm)
</ot>
objDom = ADsOpenObject("LDAP:/ ...
print ???"all attributes"??? of objDom


Look at dir() and the inspect module.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Apr 27 '06 #2
Thanks for your tips.
But dir() and inspect did not really help.

dir():
['GetIDsOfNames', 'GetTypeInfo', 'GetTypeInfoCount', 'Invoke',
'InvokeTypes', 'QueryInterface', '_ApplyTypes_', '_FlagAsMethod',
'_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__',
'__LazyMap__', '__call__', '__cmp__', '__doc__', '__getattr__',
'__getitem__', '__init__', '__int__', '__len__', '__module__',
'__nonzero__', '__repr__', '__setattr__', '__setitem__', '__str__',
'_builtMethods_', '_enum_', '_find_dispatch_type_',
'_get_good_object_', '_get_good_single_object_', '_lazydata_',
'_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_',
'_print_details_', '_proc_', '_unicode_to_string_', '_username_',
'_wrap_dispatch_']

pprint.pprint(inspect.getmembers(objDom)):
[('GetIDsOfNames',
<built-in method GetIDsOfNames of PyIDispatch object at 0x00AB7BFC>),
('GetTypeInfo',
<built-in method GetTypeInfo of PyIDispatch object at 0x00AB7BFC>),
('GetTypeInfoCount',
<built-in method GetTypeInfoCount of PyIDispatch object at
0x00AB7BFC>),
('Invoke', <built-in method Invoke of PyIDispatch object at
0x00AB7BFC>),
('InvokeTypes',
<built-in method InvokeTypes of PyIDispatch object at 0x00AB7BFC>),
('QueryInterface',
<bound method ADSIDispatch.QueryInterface of <COMObject Dispatch
wrapper around <PyIDispatch at 0xab7bfc with obj at 0x2625c8>>>),
('_ApplyTypes_',
<bound method ADSIDispatch._ApplyTypes_ of <COMObject Dispatch
wrapper around <PyIDispatch at 0xab7bfc with obj at 0x2625c8>>>),
...
Further more this nice method also did not know any more:
objDom._print_details_():

AxDispatch container Dispatch wrapper around <PyIDispatch at 0xab7bfc
with obj at 0x2625c8>
Methods:
Props:
Get Props:
Put Props:

Any additional hint ?
Could it be, that you must know in advance, what to ask a com object;
so there is no dump possibility ?

Thanks
Wolfgang

Apr 28 '06 #3
eicwo01 wrote:
Thanks for your tips.
But dir() and inspect did not really help.


Really ?

def dump(obj):
for name in dir(obj):
print getattr(obj, name)

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Apr 28 '06 #4
bruno at modulix wrote:
eicwo01 wrote:
Thanks for your tips.
But dir() and inspect did not really help.


Really ?

def dump(obj):
for name in dir(obj):
print getattr(obj, name)


That will show him the attributes of the Python wrapper around the COM
object, it won't show him the attributes of the underlying COM object
itself.

If I remember correctly (and its a while since I did this), you may be able
to use win32com/client/makepy.py to generate a .py file from a type
library. If you do this then the python wrapper will have methods to
forward the calls, so you can inspect it as above. Unfortunately, not all
COM objects have to have type libraries, so it isn't always possible to do
this and then you have to fall back on reading the documentation for
whatever COM object you are using.

You can also embed a call to gencache.EnsureModule() into your code to
generate the needed wrappers automatically: the output from makepy tells
you this.

The easy way to run makepy is to run PythonWin and use 'COM makepy utility'
from its tool menu. Then all you have to do is figure out which of the type
libraries in the system is the relevant one.
Apr 28 '06 #5
Duncan Booth wrote:
bruno at modulix wrote:

eicwo01 wrote:
Thanks for your tips.
But dir() and inspect did not really help.


Really ?

def dump(obj):
for name in dir(obj):
print getattr(obj, name)

That will show him the attributes of the Python wrapper around the COM
object, it won't show him the attributes of the underlying COM object
itself.


I stand corrected - and shouldn't answer questions about MS technos :(

(snip)

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Apr 28 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Samuel M. Smith | last post: by
3 posts views Thread by redefined.horizons@gmail.com | last post: by
26 posts views Thread by tjhnson@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.