Use a COM-server with python

Jeff Shannon jeff at ccvcorp.com
Wed Nov 7 19:19:57 EST 2001


dsavitsk wrote:

> "Marc Gehling" <m.gehling at gmx.de> wrote in message
> news:3BE83CFC.7060103 at gmx.de...
> > Hello,
> >
> > I installed a comserver and i can use it with VB. I would like to use
> > the server with python. I read some artikels and take a look at "python
> > programming on win32".
> >
> > Can someone translate this vb into python ?
> >
> > Dim oRepo As MXLib.MXRepository
> ......
> > oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators",
> > oNewFolder
>
> >>> oRepo.CreateFolder("testfolder", "folderdescr", 0, "Administrators")
> >>> # oNewFolder # not sure what this i as it was never set in the vb
> example

I can't be sure without looking at the specifics for that COM api, but many COM
objects return values through "out" parameters--passed by reference.  (This is
because COM uses return values to indicate errors.)  Since Python doesn't
support the usual notion of passing by reference, the PythonCOM implementation
translates "out" parameters into return values (and error returns into
exceptions).  Therefore, (presuming that oNewFolder is indeed an "out" param),
this final line should be written as:

oNewFolder = oRepo.CreateFolder('testfolder', \
                                 'folderdesc', 0, 'Administrators')

Hope that helps...

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list