-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
51 lines (37 loc) · 1.16 KB
/
Copy pathutils.py
File metadata and controls
51 lines (37 loc) · 1.16 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from time import time
def timer(func):
def wrap_function(*args, **kwargs):
t1 = time()
try:
result = func(*args, **kwargs)
return result
finally:
t2 = time()
print(f'Function {func.__name__!r} executed in {(t2-t1): .4f}s')
return wrap_function
def color(color_num):
# Black: 30, Red: 31, Green: 32, Yellow: 33
# Blue: 34, Magenta: 35, Cyan: 36, White: 37
print(f'test test [{color_num}misThisRed?[0m test test')
# counter = [0]
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def __str__(self):
return "({}, {})".format(self.x, self.y)
def __repr__(self):
return "Point({}, {})".format(self.x, self.y)
def __eq__(self, value):
# global counter
# counter[0] = counter[0] + 1
return (
isinstance(value, Point)
and self.x == value.x
and self.y == value.y
)
def __hash__(self):
return self.x + self.y
def __neg__(self):
return Point(-self.x, -self.y)
def __add__(self, point):
return Point(self.x+point.x, self.y+point.y)