forked from python-validators/validators
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextremes.py
More file actions
65 lines (45 loc) · 1.07 KB
/
extremes.py
File metadata and controls
65 lines (45 loc) · 1.07 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
try:
from functools import total_ordering
except ImportError:
# Use Python 2.6 port
from total_ordering import total_ordering
@total_ordering
class Min(object):
"""
An object that is less than any other object (except itself).
Inspired by https://pypi.python.org/pypi/Extremes
Examples::
>>> import sys
>>> Min < -sys.maxint
True
>>> Min < None
True
>>> Min < ''
True
.. versionadded:: 0.2
"""
def __lt__(self, other):
if other is Min:
return False
return True
@total_ordering
class Max(object):
"""
An object that is greater than any other object (except itself).
Inspired by https://pypi.python.org/pypi/Extremes
Examples::
>>> import sys
>>> Max > Min
True
>>> Max > sys.maxint
True
>>> Max > 99999999999999999
True
.. versionadded:: 0.2
"""
def __gt__(self, other):
if other is Max:
return False
return True
Min = Min()
Max = Max()