How to append a "timer" inline with a print statement?
<p>I didn't actually able to come up with the best suitable title for this. But the problem is: I have this little function, which prints a count up timer on the screen:</p>

<pre><code>def timer(x):
  for i in range(1,x):
    sys.stdout.write("\r%d" % i)
    sys.stdout.flush()
    sleep(1)
    sys.stdout.write('\r  \r')
</code></pre>

<p>How can I append the timer at the end of a print statement, like: <code>Now counting.... 3</code>? I tried this:</p>

<pre><code>sys.stdout.write('Now counting..... ')
timer(6)
</code></pre>

<p>But it's printing the timer in the beginning of the line, replacing first two characters. Any help greatly appreciated. Cheers!!</p>
