[Tutor] How do use c/c++ methods in Python?

Alan G alan.gauld at freenet.co.uk
Mon Aug 29 12:24:37 CEST 2005


> Subject: [Tutor] How do use c/c++ methods in Python?
>

> Function Test(Struct A *a,int b). 
> I want to use this function in Python,What 
> should be the firt parameter?

I'm not sure what you are asking here.
To use a C++ function/method from Python you will need to write 
a wrapper around the C++ code, probably using SWIG or some similar
tool.

Is this what you are trying to do? And if so are you asking how 
to map the C struct to a Python type within the wrapper?

Or are you trying to call the function directly? That won't be 
possible, although if its a Windows function the ctypes library 
may help, and may provide guidance on how to translate the struct.

Can you clarify what you are trying to achieve?

Alan G


More information about the Tutor mailing list