Making progress01.14.16 · python
Progress bars are a key component of graphical user interfaces. The growing percentage and expanding bar can have a big psychological effect. They calm you down during tense situations like an OS install / recovery. And they get you psyched when you’re downloading a game or playing a new level.
You probably don’t see progress bars in the console that often, (maybe in cURL & Homebrew), but they’re becoming more common.
If you’re writing a Python script with loops, tqdm makes it super simple to add a progress bar to your console output. Here it is in action:
In it’s default configuration, tqdm shows you percentage completion, which iteration you’re on, how many iterations it’s processing per second, and the total time elapsed. Pretty neat right? And using the library is stupid easy. All you have to do is import the library and wrap your iterable in a new instance:
```python from tqdm import tqdm
wrap the iterable in a tqdm()
for i in tqdm(foo):
# loop logic goes here print i ```
Seriously, that’s it!