API\dll

Trent Mick trentm at ActiveState.com
Tue Jan 9 11:09:09 EST 2001


On Tue, Jan 09, 2001 at 02:52:28PM +1100, Ben Catanzariti wrote:
> Hi,
> 
> This may seem like a simple q for a lot of you?
> 
> I have an API with a dll. To call Functions from this dll the examples for
> the API are written in C. However I would like to use Python to make the
> same function calls. Does the dll have to be written specifically in the
> language that is making the call to do this... in this case C? Or can Python
> make calls to any dll?

You have to write a Python/C extension that will mediate calls between your
Python code and the C API of your DLL. You will need to write that wrapper in
C. You should read the "Extending and Embedding the Python Interpreter"
section of the main Python docs.

An excerpt:
   It is quite easy to add new built-in modules to Python, if you know how to
   program in C. Such extension modules can do two things that can't be done
   directly in Python: they can implement new built-in object types, and they
   can call C library functions and system calls. 

http://velocity.activestate.com/docs/ActivePython/ext/ext.html



Cheers,
Trent


-- 
Trent Mick
TrentM at ActiveState.com




More information about the Python-list mailing list