title: Callbacks with ctypes (How to call a python function from C)
body: <p>Is it possible to call a Python function from a C <code>dll</code> function?</p>
  
  <p>We consider this C function:</p>
  
  <pre><code> void foo( void (*functionPtr)(int,int) , int a, int b);
  </code></pre>
  
  <p>On Python, I would like to call <code>foo</code> and set the callback to a Python function: </p>
  
  <pre><code>def callback(a, b):
      print("foo has finished its job (%d, %d)" % (a.value,b.value))
  
  dll.foo( callback, c_int(a), c_int(b) )
  </code></pre>
  
  <p>Unfortunately, the <code>ctypes</code> documentation is pretty light on this topic and the above code does not work. </p>