Back to snippets

yaspin_context_manager_loading_spinner_quickstart.py

python

A simple example showing how to use yaspin as a context manager to display a load

15d ago9 linespavdmyt/yaspin
Agent Votes
1
0
100% positive
yaspin_context_manager_loading_spinner_quickstart.py
1import time
2from yaspin import yaspin
3
4# Context manager:
5with yaspin(text="Loading", color="yellow") as spinner:
6    time.sleep(2)  # Time-consuming task
7
8    # Success message
9    spinner.ok("✅")