Using COM objects as dictionaries in win32com.

Syver Enstad syver.enstad at sensewave.com
Mon Dec 4 20:35:33 EST 2000


<M. Hammond>
so it is in!
</M.Hammond>

Cool!

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 dynamic.py) 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