Created
June 29, 2019 08:09
-
-
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
This file contains 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
#!/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