-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
- I have marked all applicable categories:
- documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
- new feature request
- I have visited the source website, and in particular
read the known issues - I have searched through the issue tracker for duplicates
- I have mentioned version numbers, operating system and
environment, where applicable:import tqdm, sys print(tqdm.__version__, sys.version, sys.platform)
Enviroment: tqdm.__version__='4.67.1', sys.version='3.12.11 (main, Jun 3 2025, 15:41:47) [Clang 17.0.0 (clang-1700.0.13.3)]', sys.platform='darwin'
Hello, I'm looking to use tqdm
when I lazily evaluate a bunch of items with a known upper bound.
def scenarios(max_amount: int) -> Generator[str, None, None]:
for i in range(max_amount):
yield str(i)
def valid(x: str) -> bool:
return x == '57'
n = 1000
with tqdm.tqdm(total=n) as pbar:
for item in scenarios(n):
pbar.update()
if valid(item):
break
The above outputs something like
6%|████▌ | 58/1000 [00:00<00:00, 666492.14it/s]
Instead I would like to output a complete progress bar when my loop exits early (at the break
line). I was thinking this could be accomplished with a new flag for tqdm.tqdm
(preferred) or a new .complete()
function. Thanks for looking.
Metadata
Metadata
Assignees
Labels
No labels