> >> Well, thats basically what I am doing now, but these object > >> structures that are returned can be arbitrarily complex, with lists > >> of objects that contain other kinds of objects, which have lists > >> of even more objects. Having to walk through arbitrary object > >> structures and look for lists/tuples of other objects, > etc. is a bit > >> of a pain, and I am not sure if I can really do this reliably. > > > > You don't need to recurse deeply though. If all your > objects use the > > same policy, the sub-objects will work automatically > > Really? This is not my experience. I am using whatever the default > policy is on all of my objects, and a test case very much like my > "Person" and "Title" example below fails unless I loop through the > `titles` attribute of my Person instances and manually wrap the Title > instances before returning the Person instance. > > Am I doing something wrong? Do I need to use a different policy to > make this happen?
It should work as described. Logically, there should be no need to wrap an object until it is actually passed via COM. ie, if the person.titles attribute was never referenced it should never need to be wrapped - which implies it could be wrapped as late as possible rather than as early as possible. > > It might get a little complicated though with respect to object > > identity. > > Fair enough, but this wouldn't be an issue in my case. I am only > passing back and forth instances that have a unique ID on them, and > use that for all comparisons. But, I see your point :) Yes, this is a point I would need to consider before adding the facility to pythoncom - it must work in the general case. Cheers, Mark _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32