ctypes

Another way to extend Python is via the ctypes module

ctypes web page

With ctypes, one can access a system library and get pointers to functions within it

These functions are normally only callable from languages like C

ctypes creates Python function objects to wrap them

It also converts between Python & C data types for arguments and return values

Example:

import ctypes

libgl = ctypes.cdll.LoadLibrary('/usr/lib/libGL.so')

glMultiTexCoord2dARB = libgl.glMultiTexCoord2dARB
glMultiTexCoord2dARB.argtypes =  [ ctypes.c_uint , ctypes.c_double , ctypes.c_double ]

glGetError = libgl.glGetError
glGetError.argtypes =  [ ]
glGetError.restype = ctypes.c_uint

next