Skip to content
This repository was archived by the owner on Dec 13, 2020. It is now read-only.
This repository was archived by the owner on Dec 13, 2020. It is now read-only.

simple usage example misleading #5

@thorstenkampe

Description

@thorstenkampe

The simple usage example assumes that the total number of items to process is 5 and iterates over range(5 + 1) (= 6) items in order to draw a full 100%. Obviously you cannot iterate six times in a loop over a list of five items.

The following shows a "real life" usage example:

progress_set = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

total = len(progress_set)
bar   = ProgressBar(total)

for index, item in enumerate(progress_set):
    bar.numerator = index
    print(bar, end = '\r')

    # do stuff with item of progress_set
    time.sleep(0.25)

bar.numerator += 1
print(bar)

example.py shows in progress_bar() print(bar) # Always print one last time. This is probably an - incomplete - remainder of the correct usage. The author just forgot to increment the numerator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions