Skip to content

Commit 6a4e6dd

Browse files
pradeep90jonathanslenders
authored andcommitted
Fix example for progress bar with custom iterable
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] ```
1 parent be4ccdf commit 6a4e6dd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/pages/progress_bars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ in order to make displaying the progress possible:
5050
yield ...
5151
5252
with ProgressBar() as pb:
53-
for i in pb(some_iterable, total=1000):
53+
for i in pb(some_iterable(), total=1000):
5454
time.sleep(.01)
5555
5656

0 commit comments

Comments
 (0)