- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.py
More file actions
Latest commit
17 lines (16 loc) · 439 Bytes
/
Copy pathprogress.py
File metadata and controls
17 lines (16 loc) · 439 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3
defprogress(i, n, length=30):
# Get length if iterable has been passed
try: n=len(n)
exceptTypeError: pass
# Ensure i and n are valid
assertisinstance(n, int)
assert (n>0)
assert (i>=0)
assert (i<=n-1)
# Output
prog= (i+1) /n
filled="="*int(prog*length)
print('\r', f'[{filled:{length}}] {100*prog:.1f}%', end='')
if (prog==1):
print()