#!/usr/bin/python #This creates a callback for use as a C function pointer from ctypes import * comp=cdll.LoadLibrary("./libtrivial.so") def mx(a,b): return b if b>a else a compare=comp.compare #No need to change the result type, because it already assumes integer #Let's get ready for our callback: callableobject=CFUNCTYPE(c_int,c_int,c_int) #return, 1st arg, 2nd arg callback=callableobject(mx) print compare(5,7,callback) print compare(7,5,callback)