Using COM objects as dictionaries in win32com.

Syver Enstad syver.enstad at
Tue Dec 5 02:35:33 CET 2000

<M. Hammond>
so it is in!


I fiddling with an implementation of items() in CDispatch, so that one could
use f.ex
the Session.Contents object in ASP like this:

for key, value in Session.Contents.items:
    #do stuff

There some more work to do there as strange things happen when I apply the
method to objects that don't really support it. I guess another problem is
that I've implemented as a method in CDispatch (in and then
won't work on make_py generated classes won't it.

Anyway, my fiddlings so far has produced this, that works with
Session.Contents and a couple of other objects, but hangs the web server
when applied to the Request object (works fine on Request.QueryString and
Request.Form though)

    def items(self):
        ret = []
        for each in self:
            ret.append( each, self[each]) )
        return tuple(ret)

More information about the Python-list mailing list