Jeremy Herbert
2014-09-15 15:53:04 UTC
Hi all,
I'm currently struggling a little with pywin32, and to me it seems
that the default python dir() behaviour is broken. For the record, I
am forcing early-binding.
To explain, I think some code would be best:
class A(object):
def __init__(self):
self.member = 1
def hello(self):
print "test"
tmp = A()
dir(tmp)
###
The following is printed in iPython:
Out[4]:
['__class__',
'__delattr__',
'__dict__',
'__doc__',
'__format__',
'__getattribute__',
'__hash__',
'__init__',
'__module__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'hello',
'member']
Note that both member functions and variables are present. When I run
dir() on a COM object instance however, it does not show any of the
member properties, just the member functions. So if the A class was
instantiated as an COM object, it would only show "hello" as well as
the builtins in the printout, and "member" would be missing.
Given that I am trying to interact with Autodesk Inventor, and 90% of
the functionality of the COM interface is via properties, this is
quite frustrating! Is there any way to list all of the properties of a
COM object instance?
Thanks,
Jeremy Herbert
I'm currently struggling a little with pywin32, and to me it seems
that the default python dir() behaviour is broken. For the record, I
am forcing early-binding.
To explain, I think some code would be best:
class A(object):
def __init__(self):
self.member = 1
def hello(self):
print "test"
tmp = A()
dir(tmp)
###
The following is printed in iPython:
Out[4]:
['__class__',
'__delattr__',
'__dict__',
'__doc__',
'__format__',
'__getattribute__',
'__hash__',
'__init__',
'__module__',
'__new__',
'__reduce__',
'__reduce_ex__',
'__repr__',
'__setattr__',
'__sizeof__',
'__str__',
'__subclasshook__',
'__weakref__',
'hello',
'member']
Note that both member functions and variables are present. When I run
dir() on a COM object instance however, it does not show any of the
member properties, just the member functions. So if the A class was
instantiated as an COM object, it would only show "hello" as well as
the builtins in the printout, and "member" would be missing.
Given that I am trying to interact with Autodesk Inventor, and 90% of
the functionality of the COM interface is via properties, this is
quite frustrating! Is there any way to list all of the properties of a
COM object instance?
Thanks,
Jeremy Herbert