class progressbar(i=None, maxiters=None, label='', every=1, length=30, empty='—', full='•', newline=False, flush=False, **kwargs)[source]#

Show a progress bar for a for loop.

It can be called manually inside each iteration of the loop, or it can be used to wrap the object being iterated. In the latter case, it acts as an alias for the tqdm.tqdm() progress bar.

  • i (int/iterable) – current iteration (for text output), or iterable object (for tqdm)

  • maxiters (int) – maximum number of iterations (can also use an object with length)

  • label (str) – initial label to print

  • every (int/float) – if int, print every “every”th iteration (if 1, print all); if float and <1, print every maxiters*every iteration

  • length (int) – length of progress bar

  • empty (str) – character for not-yet-completed steps

  • full (str) – character for completed steps

  • newline (bool) – whether to print each iteration on a new line

  • flush (bool) – whether to force-flush the buffer

  • kwargs (dict) – passed to tqdm.tqdm(); see its documentation for full options


# Direct usage inside a loop
for i in range(20):
    sc.progressbar(i+1, 20)

# Direct usage inside a loop with custom formatting
for i in range(1000):
    sc.progressbar(i+1, 1000, every=100, length=10, empty=' ', full='✓', newline=True)

# Used to wrap an iterable, using tqdm
x = np.arange(100)
for i in sc.progressbar(x):

Adapted from example by Greenstick (

New in version 1.3.3: “every” argument
New in version 3.0.0: wrapper for tqdm