Files
weather-info/pico-client/utils/simple_counter.py

39 lines
682 B
Python

class SimpleCounter:
_value: int
def __init__(self):
self._value = 0
@property
def value(self):
return self._value
@value.setter
def value(self, value):
self._value = value
# Arithmetic operators
def __add__(self, other):
return self._value + other
def __sub__(self, other):
return self._value - other
# In-place operators
def __iadd__(self, other):
self._value += other
return self
def __isub__(self, other):
self._value -= other
return self
# Conversion and representation
def __int__(self):
return self._value
def __str__(self):
return str(self._value)
def __repr__(self):
return f"SimpleCounter(value={self._value})"