title: Cython: redirect output to file of C function to Python string
body: <p>I have a C function that writes output to a file (<code>.pxd</code> file definition follows):</p>
  
  <pre><code>int write_prob(ProbObj* problem, const char* fname)
  </code></pre>
  
  <p>(This writes a human-readable formulation of <code>problem</code> to a file named <code>fname</code>.) I would like to use this function from Python, but with output redirected to a Python string. I have looked at the tempfile module, but do not really know how to approach the problem.</p>
  
  <p>I do know how to wrap the function in a <code>.pyx</code> file, just not how to do the redirection.</p>