Hi Tim, Sorry, I did not intend for my message to be interpreted as overly harsh :) Is there any way to introspect the properties of the objects at runtime using python? They are present in the makepy file under _prop_map_get_.
Thanks, Jeremy Herbert On Mon, Sep 15, 2014 at 7:33 PM, Tim Roberts <t...@probo.com> wrote: > Jeremy Herbert wrote: >> 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. > > "Broken" is too harsh of a word. What you're seeing here is more or > less an impedance mismatch between two very different interfaces. > > The Python dir() function knows about Python objects living in the > Python object space. COM objects live in an entirely different space. > Python, being cross-platform, doesn't have any internal knowledge about > COM, which is strictly a Windows concept. > > The win32com code does its best to provide a bridge between those > worlds, by providing a simulated Python object that satisfies most of > the Python object requirements, but proxies its activities to the COM > object it is wrapping. In the case of early binding, the only way > win32com can do that is by parsing the TLB to figure out the object > layout. If you look at the Python file generated by makepy, do you see > the properties there? > > One interesting side note is that COM doesn't really have the notion of > properties, because many languages don't support them. When an object > supports a Color property, that's actually implemented by having methods > called get_Color and set_Color. You might see if those are in the > makepy file. > > >> 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. > > You do need to remember that you're not really looking at a COM object > instance. You're looking at a win32com proxy that is communicating with > the COM object. It's doing the best it can with the information it can > extract, but if the TLB doesn't include everything, makepy can't make it up. > > >> 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? > > Check the makepy file and see if they are present. > > -- > Tim Roberts, t...@probo.com > Providenza & Boekelheide, Inc. > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > https://mail.python.org/mailman/listinfo/python-win32 _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32