Skip to content

Is there a way to reset elapsed time without recreating the object? #648

@ydixon

Description

@ydixon

I want to do something like this, but i also want the elapsed timer to be reset to 0.

with tqdm(file=sys.stdout, leave=False, total=batch_length) as pbar:
    for i in data:
        pbar.update(1)
        time.sleep(1)
        if some_condition:
            pbar.n = 0

Or is this the only way to achieve it?

pbar = tqdm(file=sys.stdout, leave=False, total=batch_length)
for i in data:
    pbar.update(1)
    time.sleep(1)
    if some_condition:
        pbar.close()
        pbar = tqdm(file=sys.stdout, leave=False, total=batch_length)

Metadata

Metadata

Assignees

Labels

question/docs ‽Documentation clarification candidate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions