-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparison.py
43 lines (34 loc) · 989 Bytes
/
comparison.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
36
37
38
39
40
41
42
43
from __future__ import unicode_literals
def _equals_(a, b):
"""Checks whether two values equal each other."""
if isinstance(a, list):
if not isinstance(b, list):
return False
if len(a) != len(b):
return False
for index, item in enumerate(a):
if item != b[index]:
return False
return True
if isinstance(a, dict):
if not isinstance(b, dict):
return False
if len(a) != len(b):
return False
for k, v in a.items():
if k not in b or v != b[k]:
return False
return True
return a == b
def _less_(a, b):
"""Checks whether the first value is less than the second value."""
return a < b
def _lessorequals_(a, b):
"""Checks whether the first value is less than or equal to the second value."""
return a <= b
def _greater_(a, b):
"""Checks whether the first value is greater than the second value."""
return a > b
def _greaterorequals(a, b):
"""Checks whether the first value is greater than or equal to the second value."""
return a >= b