473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
5 6979
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Samuel M. Smith | last post by:
I have been playing around with a subclass of dict wrt a recipe for setting dict items using attribute syntax. The dict class has some read only attributes that generate an exception if I try to...
3
by: redefined.horizons | last post by:
I've been reading about Python Classes, and I'm a little confused about how Python stores the state of an object. I was hoping for some help. I realize that you can't create an empty place holder...
1
by: LG | last post by:
I want to add attributes to a custom dropdownlist and I found some code on Internet that doesn't work after post back. First time the control has the attributes, but after postback the attributes...
26
by: tjhnson | last post by:
Hi, With properties, attributes and methods seem very similar. I was wondering what techniques people use to give clues to end users as to which 'things' are methods and which are attributes. ...
11
by: Rafe | last post by:
Hi, I'm working within an application (making a lot of wrappers), but the application is not case sensitive. For example, Typing obj.name, obj.Name, or even object.naMe is all fine (as far as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.