-
Notifications
You must be signed in to change notification settings - Fork 0
/
t.py
36 lines (25 loc) · 857 Bytes
/
t.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import time
import io
old_print = print
def new_print(*args, sep=" ", file=None, **kwargs):
kwargs.pop('flush', False)
for arg in args:
for c in str(arg):
old_print(c, file=file, end="", flush=True)
time.sleep(0.02)
if len(args) > 1:
old_print(sep, file=file, end="")
time.sleep(0.2)
old_print(**kwargs, flush=True)
print = new_print
def print_backwards(*args, sep=" ", file=None, **kwargs):
_file = io.StringIO()
old_print(*args, sep=sep, file=_file, end="", **kwargs)
_str = _file.getvalue()
size = len(_str)
_new_str = _str
time.sleep(0.2)
for i in range(size+1):
old_print("\r" + _new_str[:(size-i)] + " " * i, end="")
old_print("\r" + _new_str[:(size-i)], end="", flush=True)
time.sleep(0.02)