Skip to content

Instantly share code, notes, and snippets.

@tomwolber
Created November 11, 2011 21:38
Show Gist options
  • Save tomwolber/1359380 to your computer and use it in GitHub Desktop.
Save tomwolber/1359380 to your computer and use it in GitHub Desktop.
python sleeeeeeep
import time
import sys
// This sleeps for 10 secs, then prints a bunch of stars
for i in range(10):
time.sleep(1)
print '*',
// Same here
In [16]: for i in range(10):
time.sleep(1)
sys.stdout.write('*')
// This works as expected
for i in range(10):
time.sleep(1)
print '*'
@tomwolber
Copy link
Author

SOLUTION

import time
import sys

for i in range(10):
    sys.stdout.write('*')
    time.sleep(1)
    sys.stdout.flush()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment