Created
April 5, 2024 10:27
-
-
Save miraculixx/0150456dea7d55d73d8ac0807da7092e to your computer and use it in GitHub Desktop.
drop-in replacmement for time.sleep (python)
This file contains hidden or 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
def wait(s, delay=1): | |
""" | |
drop-in for time.sleep() with status updates and Ctrl-C support | |
Usage: | |
for delay in wait(seconds): | |
print(f'waiting for {delay} seconds') | |
""" | |
import time | |
try: | |
while s: | |
yield str(s) | |
time.sleep(delay) | |
s -= 1 | |
except KeyboardInterrupt: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I hand-crafted this, then I got curious if ChatGPT could do it, here's how that went