A Terminal Spinner in Python

We are going to build a spinning status indicator that runs while other code is executing. It will look like this: Why? You’ve got some code that takes a while to run. import time import random def slow_func(): seconds = random.randint(2, 5) time.sleep(seconds) print("Done!") if __name__ == '__main__': slow_func() Now, when you execute this, you’ll see the following: You’ll wonder whether your code or your system is working correctly or frozen....

June 25, 2022 · 4 min · 682 words