Calling C libraries from a Python script

Thomas Heller theller at python.net
Mon Apr 7 07:41:42 EDT 2003


a-steinhoff at web.de (Armin Steinhoff) writes:

> Thomas Heller <theller at python.net> wrote in message news:<r88gc37v.fsf at python.net>...
> > joshua at goodish.org (Joshua Goodlett) writes:
> > 
> > > I'm trying to find examples of calling C library functions from within
> > > a Python script.  Any advice or pointers on where to look for examples
> > > would be appreciated.
> > 
> > If the C library is a dll, you could use ctypes.
> 
> Such DLLs must also be conform to the  _cdecl call convention ... isn't it ?

No. ctypes supports __stdcall as well, and at least one user
has wrapped a Delphi dll (__stdcall, but with reverse argument order,
IIRC).

For __stdcall, use the windll object to access the dll, for __cdecl
use cdll.

Thomas




More information about the Python-list mailing list