Skip to content

Instantly share code, notes, and snippets.

@gnuton
Created February 14, 2016 09:17
Show Gist options
  • Select an option

  • Save gnuton/3c7a46447d2be0aee0b2 to your computer and use it in GitHub Desktop.

Select an option

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")
@HENRYMARTIN5

Copy link
Copy Markdown

Thanks! Helped me a lot!

@0xGhazy

0xGhazy commented Aug 19, 2020

Copy link
Copy Markdown

thanks pro <3

@Arikakate

Copy link
Copy Markdown

How does this code work?

@gnuton

gnuton commented Oct 12, 2020

Copy link
Copy Markdown
Author

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
Copy Markdown

doesnt work?

@gnuton

gnuton commented May 18, 2021

Copy link
Copy Markdown
Author

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