title: Python ctypes function pointer
body: <p>I created a C-library with a number of functions that I can call from python using ctypes. I've got my head around some of the simpler ones but I'm stumped by how I pass the right arguments to the following function:</p>
  
  <pre><code>foo(double *, double *, void(*f1)(double *, double *, double, struct sys *),
      void(*f2)(double *, double *, double, struct sys *), struct sys *, double *,
      double, double, int, int, gsl_rng *)
  </code></pre>
  
  <p>My starting point is setting the <code>.argtypes</code> for the function. I've got the double arrays sorted with <code>POINTER(100*c_double)</code> etc.</p>
  
  <p>However, I am stuck on how to pass the function pointers. I have a number of functions (of the form of f1 and f2), which reside in the same library as <code>foo</code> that I would like to pass as arguments to <code>foo</code>.</p>
  
  <p>I think I've managed pass the struct sys* pointer ok by using the following code:</p>
  
  <pre><code>class sys(Structure):
      _fields_ = [("alpha", c_double),
                  ("sigma", c_double)]
  </code></pre>
  
  <p>and then using <code>POINTER(sys)</code> as the <code>argtype</code> there. Finally, the <code>gsl_rng</code> is a typical random number generator from the GNU Scientific Library; I don't know where to start here.</p>
  
  <p>Can anybody shine some light on the complicated ctypes?</p>