Basic Python ctypes
December 9, 2009
The easiest way to call C from Python seems to be ctypes.
Simple Example on Windows
>>> import ctypes
>>> libc = ctypes.CDLL("msvcrt")
>>> print libc.strlen("Hello!")
6
>>> libc.printf("Argument");
Argument8
>>> num_bytes = libc.printf("the number %d and string %s\n", 10, "spam")
the number 10 and string spam
>>> print num_bytes …

