Python print on same line after delay
<p>This is my code:</p>

<pre><code>def get(url):
    print 'GET: ' + url,
    r = requests.get(url)
    print 'DONE'
    return r

get('https://www.###.com/getfoo')
</code></pre>

<p>The output:</p>

<blockquote>
  <p>GET: <a href="https://www.###.com/getfoo">https://www.###.com/getfoo</a> DONE</p>
</blockquote>

<p><br/>
 <code>request.get</code> needs about 5 seconds to get a result. <em>However</em> the output displays after those 5 sec, not the first imedeately and the <strong>DONE</strong> after 5 seconds. </p>

<p>Why?</p>

<p>Because the console is line-buffering the output. Call <code>sys.stdout.flush()</code> in order to flush it.</p>

python