Python win32 dll

Mark Hammond mhammond at skippinet.com.au
Tue Aug 12 21:31:23 EDT 2003


Karl Lopes wrote:

> Hello all,
>   I would like to implement a COM server using python. 
>   This server is based on an interface which was given to me in Visual Basic.
>   
>   For example one of the methods in the interface is:
>   Public Sub CreateLogFile(ByVal LogFilePath AS String, 
>                            ByRef LogFileIntf As LogFile);
> 
> 
>  1. The corresponding Python method would be:   
>     def CreateLogFile( self, LogFilePath, LogFileIntf ). Is this correct?

Probably <wink>

>  2. Is there a difference in the way Python implements ByVal and ByRef?

In Python you need to *return* any out values.  eg:

def CreateLogFile( self, LogFilePath, LogFileIntf ):
   ...
   return new_file

You must declare LogFileIntf, as VB will always pass it as it has no 
real concept of an "out" param, just "in" or "inout".  However, if this 
interface was actually declared in a type library/IDL (which *does* make 
the distinction), you may find that LogFileIntf is declared "out", which 
would mean you do *not* declare the param in the Python function (even 
though you still would if you were implementing the interface in VB).

Yes, I know, it sucks <wink>

Mark.





More information about the Python-list mailing list