Created
March 26, 2022 11:28
-
-
Save samuelcolvin/2f0240cd809dde293b79aba1f74e2019 to your computer and use it in GitHub Desktop.
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 python3 | |
import time | |
clocks = ['π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π'] | |
# moves the cursor to the beginning of the line | |
# (3 columns back in this case is always enough) | |
reset_cursor = '\033[3D' | |
i = 0 | |
while True: | |
try: | |
clock = clocks[i % len(clocks)] | |
print(f'{reset_cursor}{clock} ', end='', flush=True) | |
i += 1 | |
time.sleep(1 / 20) | |
except KeyboardInterrupt: | |
# print the exact time and exit | |
print(reset_cursor) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment