Reputation: 2093
I've got this function that takes some time to complete and I'd like to display the current progress per element in the list.
This is how it's coded:
import progressbar
def func(self):
bar = progressbar.ProgressBar(
maxval=len(some_list),
widgets=[progressbar.Bar('=', '[', ']'), ' ', progressbar.Percentage()]
)
progress = 0
bar.start()
for r in some_list:
#heavy calculation
progress += 1
bar.update(progress)
bar.finish()
Yet when I run, the progressbar isn't displayed (nothing in fact is), the function just does its thing and when the function ends 20 seconds later I suddenly get the full bar in the console
What am I doing wrong?
I'm using Kubuntu latest version with python 3.7.4 and PyCharm.
Upvotes: 0
Views: 2504
Reputation: 4510
Consider running it not from an IDE, sometimes they get a messy std output. Just run it with plain python
like this:
python3 your_script.py
Upvotes: 3