Created
February 14, 2016 09:17
-
-
Save gnuton/3c7a46447d2be0aee0b2 to your computer and use it in GitHub Desktop.
Python slow print
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
def slowprint(s): | |
for c in s + '\n': | |
sys.stdout.write(c) | |
sys.stdout.flush() | |
time.sleep(1./10) | |
if __name__ == "__main__": | |
slowprint("This is a test of slowprint") |
Thanks! Helped me a lot!
thanks pro <3
How does this code work?
Save it in file then run it.
python x.py
it print to stdout 1 char of the string passed to the function every time the timer times out
doesnt work?
it works for me with python2 as well as python3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, could you explain, how this code works ?