Progress Bars in Python Terminal

preview_player
Показать описание
Today we learn how to create and display progress bars in the command line of a Python application.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

chr(9608) for filing bar and chr(9617) for blank

Sinke_
Автор

If you run it in PyCharm, in Run window, below the play icon is a cog icon -> under "execution" you can select "Emulate terminal in output console" . This will make the progressbar render properly (also realy usefull if you stuff from the rich libary).

aeyyatal
Автор

in python 3 the division int / int returns a float automatically. if you want integer division, you can use //.

SirFloIII
Автор

If you clicked this video looking for an already made progress bar that you can use straight away, use the "tdqm" package. It's generic, lightweight, and very good for performance, and comes with time estimation by default!

carlosmspk
Автор

Just a heads up, you can use os.system("") with an empty string argument to display colors in a cmd prompt

SpaghettDev
Автор

In fact CMD can display colors like a Unix terminal (however it won't render italics or bold or any font transforms), you just need to set a registery key called TerminalLevel to 1
Here is the command to do so

reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d

\r stands for "Carage return"

Have a great day

- 0x454d505459

nameundefined
Автор

tqdm is really good loading bar package it adjusts automatically, is performant, easy to use and provide nice infothat also includes performance optimizations so it doesn't slow down your program

Example:
from tqdm import tqdm
import time

for x in tqdm(range(100)):
time.sleep(0.01)

21%|█████████▍ | 21/100 [00:02<00:08, 9.16it/s]

ben-brady
Автор

All these years I never knew that print(..., end='\r') will actually do a carriage return to the same line in a Windows console, lol. THANKS!

michaelv
Автор

That was fun to follow along with, somewhat simple (or at least not overly complicated), and the result looks great! Thanks!

benlong
Автор

You don't need to do index + 1. enumerate function takes an optional argument `start` that defaults to 0. So you can just do enumerate(iterable, 1)

sudoggo
Автор

I don´t know how to code yet. First steps on Odin, but I bookmarked the channel.
Thanks a lot for the videos!

maurolimaok
Автор

Had been looking for something like this for a while, your videos are awesome.

vest
Автор

small video and to the point in a simple way, love it! Thanks for this

BautyParra
Автор

That moment where i was thinking about this this morning, and now it’s top of my recommendation list .-.

BlueberryCats_
Автор

Thanks a million for this video! I was just looking for such a solution ... and you saved my day! Thx, thx, thx!

manometer
Автор

The terminal can be run from PyCharm.

The bar in the bottom left hand side that says “Version Control, TODO, Problems, Terminal, Python Packages, Python Console”

Click the Terminal tab.

Imdazedandconfuzed
Автор

in cmd (or windows terminal) you can go thru all subdirectories in one command
"cd Also you can autocomplete subdir name with tab

nachoherrera
Автор

you can display the progressbars in pycharm by going to the run-config of the script and then enabeling "Emulate terminal in output console" at "Execution"

paulus_de_gross
Автор

I made a similar thing in C# in the past but the fun came when having to write code to not make the lines move to different parts of the screen upon console resize.

ReadieFur
Автор

On line 16 you dont need to make that extra calculation every time in the loop just give enumerate a starting point of one - for i, x in enumerate(numbers, 1): and you are good to go. Same is for len(numbers) you dont want to make it every loop to go and find how long is the list make a var before the loop and use that.Thats all extra calculation that you dont want to do on every loop in real life and slow your code...

BadSeymur