Slow printing - still need answers
<p>This topic has already been covered but I am still having trouble. The code I have does print the string but it prints it extremely fast. I have tried changing the time value but it doesn't seem to change anything.</p>

<p>Here is <em>everything</em> I have - Maybe I just need a more complete example?</p>

<pre><code>import sys,time,random

typing_speed = 50 #wpm
def slow_type(t):
    for l in t:
        sys.stdout.write(l)
        time.sleep(random.random()*10.0/typing_speed)
print "Tell if you think this is too fast?"
</code></pre>

<pre><code>import sys,time,random

typing_speed = 50 #wpm

def slowprint(t):
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush() # Forcing the output of everything in the buffer. 
        time.sleep(random.random()*10.0/typing_speed)

    sys.stdout.write("\n") # Printing a newline, because it looks cleaner.

slowprint ("Tell if you think this is too fast?")
</code></pre>

<p>I changed the name of the function because <code>slowprint</code> seem a little more explicit in my opinion.</p>

<p>I like the following version better - it accepts an argument to control the speed.</p>

<pre><code>import sys,time,random

def slowprint(t, s): # s is the typing speed - formally held in `typing_speed`
    for l in t:
        sys.stdout.write(l)
        sys.stdout.flush() # Forcing the output of everything in the buffer. 
        time.sleep(random.random()*10.0/s)

    sys.stdout.write("\n") # Printing a newline, because it looks cleaner.

slowprint ("Tell if you think this is too fast?", 50)
</code></pre>

python python-2.7