Turn "basic usage" progress example into a runnable example

This commit is contained in:
Darren Burns 2022-06-07 10:00:45 +01:00
parent e8a9466b94
commit df775dabb5

View file

@ -19,12 +19,13 @@ To see how the progress display looks, try this from the command line::
Basic Usage
-----------
For basic usage call the :func:`~rich.progress.track` function, which accepts a sequence (such as a list or range object) and an optional description of the job you are working on. The track method will yield values from the sequence and update the progress information on each iteration. Here's an example::
For basic usage call the :func:`~rich.progress.track` function, which accepts a sequence (such as a list or range object) and an optional description of the job you are working on. The track function will yield values from the sequence and update the progress information on each iteration. Here's an example::
import time
from rich.progress import track
for n in track(range(n), description="Processing..."):
do_work(n)
for i in track(range(20), description="Processing..."):
time.sleep(1) # Simulate work being done
Advanced usage
--------------