Skip to content

Commit

Permalink
Fix example for progress bar with custom iterable
Browse files Browse the repository at this point in the history
When I tried the example as it was, I got the following exception:

```
$ python3 /tmp/try_prompt.py
   0.0% [>                                                                                                                  ]   0/1000  eta [?:??:??]
Traceback (most recent call last):
  File "/tmp/try_prompt.py", line 8, in <module>
    for i in pb(some_iterable, total=1000):
  File "/home/pradeep/.pyenv/versions/3.10.8/lib/python3.10/site-packages/prompt_toolkit/shortcuts/progress_bar/base.py", line 353, in __iter__
    for item in self.data:
TypeError: 'function' object is not iterable
```

After changing the iterable to `some_iterable()`, things worked as expected:

```
$ python3 /tmp/try_prompt.py 
   0.1% [====================================================================================================================>]   1/1000  eta [00:00]

```
  • Loading branch information
pradeep90 authored and jonathanslenders committed Dec 12, 2023
1 parent be4ccdf commit 6a4e6dd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/pages/progress_bars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ in order to make displaying the progress possible:
yield ...
with ProgressBar() as pb:
for i in pb(some_iterable, total=1000):
for i in pb(some_iterable(), total=1000):
time.sleep(.01)
Expand Down

0 comments on commit 6a4e6dd

Please sign in to comment.