Skip to content

Instantly share code, notes, and snippets.

@gnuton
Created February 14, 2016 09:17
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save gnuton/3c7a46447d2be0aee0b2 to your computer and use it in GitHub Desktop.
Save gnuton/3c7a46447d2be0aee0b2 to your computer and use it in GitHub Desktop.
Python slow print
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")
@Totokis
Copy link

Totokis commented Oct 16, 2018

Hi, could you explain, how this code works ?

@HENRYMARTIN5
Copy link

Thanks! Helped me a lot!

@Arikakate
Copy link

How does this code work?

@gnuton
Copy link
Author

gnuton commented Oct 12, 2020

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

@beamer-jpg
Copy link

doesnt work?

@gnuton
Copy link
Author

gnuton commented May 18, 2021

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