Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 373424a

Browse files
committed
Progress bar
1 parent f646d19 commit 373424a

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

README.md

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,6 @@ def tracer(func):
14661466

14671467
Progress Bar
14681468
------------
1469-
### Tqdm
14701469
```python
14711470
# $ pip3 install tqdm
14721471
from tqdm import tqdm
@@ -1477,50 +1476,6 @@ for i in tqdm([1, 2, 3]):
14771476
sleep(0.2)
14781477
```
14791478

1480-
### Basic
1481-
```python
1482-
import sys
1483-
1484-
class Bar():
1485-
@staticmethod
1486-
def range(*args):
1487-
bar = Bar(len(list(range(*args))))
1488-
for i in range(*args):
1489-
yield i
1490-
bar.tick()
1491-
@staticmethod
1492-
def foreach(elements):
1493-
bar = Bar(len(elements))
1494-
for el in elements:
1495-
yield el
1496-
bar.tick()
1497-
def __init__(s, steps, width=40):
1498-
s.st, s.wi, s.fl, s.i = steps, width, 0, 0
1499-
s.th = s.fl * s.st / s.wi
1500-
s.p(f"[{' ' * s.wi}]")
1501-
s.p('\b' * (s.wi + 1))
1502-
def tick(s):
1503-
s.i += 1
1504-
while s.i > s.th:
1505-
s.fl += 1
1506-
s.th = s.fl * s.st / s.wi
1507-
s.p('-')
1508-
if s.i == s.st:
1509-
s.p('\n')
1510-
def p(s, t):
1511-
sys.stdout.write(t)
1512-
sys.stdout.flush()
1513-
```
1514-
1515-
#### Usage:
1516-
```python
1517-
from time import sleep
1518-
for i in Bar.range(100):
1519-
sleep(0.02)
1520-
for el in Bar.foreach([1, 2, 3]):
1521-
sleep(0.2)
1522-
```
1523-
15241479

15251480
Basic Script Template
15261481
---------------------

0 commit comments

Comments
 (0)