forked from ungleich-public/dynamicweb
16 lines
520 B
Python
16 lines
520 B
Python
class FuzzyInt(int):
|
|
def __new__(cls, lowest, highest):
|
|
obj = super().__new__(cls, highest)
|
|
obj.lowest = lowest
|
|
obj.highest = highest
|
|
return obj
|
|
|
|
def __eq__(self, other):
|
|
return other >= self.lowest and other <= self.highest
|
|
|
|
def __repr__(self):
|
|
return "[%d..%d]" % (self.lowest, self.highest)
|
|
|
|
def __hash__(self):
|
|
# Combine the hash of the lowest and highest attributes, ensuring hash consistency.
|
|
return hash((self.lowest, self.highest))
|