Skip to content

Commit fff8b85

Browse files
Refactor for readability
Co-authored-by: Ian <[email protected]>
1 parent 2306545 commit fff8b85

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

flush-print/progress.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22

33

44
def progress(percent=0, width=30):
5-
left = width * percent // 100
6-
right = width - left
7-
print(
8-
"\r[",
9-
"#" * left,
10-
" " * right,
11-
"]",
12-
f" {percent:.0f}%",
13-
sep="",
14-
end="",
15-
flush=True,
16-
)
5+
progress = (width * percent // 100)
6+
bar = "#" * progress
7+
pad = " " * (width - progress)
8+
print(f"\r[{bar}{pad}] {percent:.0f}%", end="", flush=True)
179

1810

1911
for i in range(101):

0 commit comments

Comments
 (0)