Print command-line progress bar horizontally
<pre><code>#!/usr/bin/python
import time

count  = 5
temp = True
while temp:
        if count &lt; 1:
                print "done",
                temp = False
        else:
                print "*"
                time.sleep(2)
                count -= 1
</code></pre>

<p>output:</p>

<pre><code>*
*
*
*
*
done
</code></pre>

<p>Please note that here "*" in  output is printed one after the other on the screen at the interval of 2 seconds(this is exactly what i wanted),i need to use this as a progress bar in some other code.</p>

<ol>
<li><p>I used <code>print "*",</code>
however the output is horizontal but it prints all at once after the program execution.</p>

<pre><code>&gt;&gt;&gt;* * * * * done
</code></pre></li>
<li><p>using <code>end</code> keyword gives this error.</p>

<pre><code>File "progress_1_.py", line 11
 print ("*",end = '')
                    ^
SyntaxError: invalid syntax
</code></pre></li>
</ol>

<p>Python version is Python 2.7.5 .</p>

<p>I cannot upgrade Python on this prod machine and need to deal with the existing version to get the desired output.</p>

<p>So, considering the above cases, instead of printing in new line ,can it be printed horizontally one after the other at the interval of 2 secs?</p>