Yet Another Terminal Spinner

3.4.0 · active · verified Thu Apr 09

yaspin is a Python library that provides a simple and flexible way to display terminal spinners for CLI applications, indicating ongoing operations. It is currently at version 3.4.0 and maintains a regular release cadence, often updating with new features, dependency bumps, and Python version support.

Warnings

Install

Imports

Quickstart

The most common way to use yaspin is as a context manager, wrapping your time-consuming operations. You can customize the spinner type, text, and colors, and then finalize with success or failure indicators.

import time
from yaspin import yaspin

# Basic usage as a context manager
with yaspin(text="Processing...") as sp:
    time.sleep(2) # Simulate work
    sp.ok("✔") # Mark as success

# Example with custom spinner and colors
from yaspin.spinners import Spinners

with yaspin(Spinners.earth, text="Loading data...").white.on_blue as sp:
    time.sleep(3)
    if time.time() % 2 == 0: # Simulate a random outcome
        sp.fail("✘") # Mark as failure
    else:
        sp.ok("✨") # Mark with a sparkle

view raw JSON →