Skip to content

Instantly share code, notes, and snippets.

@AlephNotation
Last active April 22, 2020 19:33
Show Gist options
  • Save AlephNotation/7c95c25a6f859d95410be3ba5690f835 to your computer and use it in GitHub Desktop.
Save AlephNotation/7c95c25a6f859d95410be3ba5690f835 to your computer and use it in GitHub Desktop.
Flash stdout centered to terminal width for extra oomph
import sys
import time
import shutil
def blink_once(input, empty_str, wait=0.05):
sys.stdout.write(f'\r{input}')
time.sleep(wait)
sys.stdout.write(f'\r{empty_str}')
time.sleep(wait)
def blink(number, text):
rows, columns = shutil.get_terminal_size((80, 20))
text = text.center(rows, "_")
empty_space = " " * rows
for x in range(0,number):
blink_once(text, empty_space)
while True:
blink(10, "Verbum caro factum est")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment