Skip to content

Instantly share code, notes, and snippets.

@elig0n
Created June 29, 2019 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elig0n/660c1c5b773490e64f611ef3662d8cc1 to your computer and use it in GitHub Desktop.
Save elig0n/660c1c5b773490e64f611ef3662d8cc1 to your computer and use it in GitHub Desktop.
Print a file/stdin to terminal character-by-character at a given speed
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import sys
if len(sys.argv) < 3:
sys.stderr.write("Need two arguments: file/- delay\n")
sys.exit(-1)
if (sys.argv[1] == "-"):
r = sys.stdin.read()
else:
f=open(sys.argv[1], "r")
r=f.read()
for b in r:
sys.stdout.write(b)
sys.stdout.flush()
time.sleep(float(sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment