[Dream] A meta-wrapper module to interface any C dynamic library

Thomas Heller theller at python.net
Fri Jul 4 13:39:17 EDT 2003


hwlgw at hotmail.com (Will Stuyvesant) writes:

>> [Seo Sanghyeon]
>> To see is to believe.
>> >>> import ctypes
>> >>> loader = ctypes.cdll
>> >>> dll = loader.msvcrt
>> >>> sin = dll.sin
>> >>> sin.argtypes = [ctypes.c_double]
>> >>> sin.restype = ctypes.c_double
>> >>> sin(3.14)
>> 0.0015926529164868282
>
> I love examples like this!  And ctypes is very good, I downloaded the
> .EXE installer and ran it and this example works "out of the box".
>
> How do you know what functions are available in "dll"?  Any general
> strategy?

On windows, you use dependency walker, although it would also be
possible to write something similar in ctypes ;-)

http://www.dependencywalker.com/

On unix like systems, I don't know. Use nm(1) ?

Thomas




More information about the Python-list mailing list