title: Where does my embedded python stdout go?
body: <p>Consider the following <a href="https://en.wikipedia.org/wiki/Minimal_Working_Example">MWE</a>:</p>
  
  <pre><code>#include &lt;Python.h&gt;
  #include &lt;stdio.h&gt;
  
  int main(void) {
    printf("Test 1\n");
    Py_Initialize();
    printf("Test 2\n");
    PyRun_SimpleString("print('Test 3')");
    printf("Test 4\n");
    return 0;
  }
  </code></pre>
  
  <p>When I compile and run this as normal i get the expected output:</p>
  
  <pre><code>$ ./test
  Test 1
  Test 2
  Test 3
  Test 4
  </code></pre>
  
  <p>But when I redirect the output I get nothing from the python code:</p>
  
  <pre><code>$ ./test | cat
  Test 1
  Test 2
  Test 4
  </code></pre>
  
  <p>What is happening? And more importantly how do I get my python output written to stdout like expected?</p>