Jan-28-2020, 04:23 PM
To check if something is in a valid range, you could do following:
In your example self.validity should be a timedelta object.
This should work:
minimum_value <= current_value <= maximum_valueAll three values should be the same data type.
In your example self.validity should be a timedelta object.
This should work:
elif self.certification_status == "Fit" and timedelta(days=730) <= self.validity <= timedelta(days=732)): return "Normal"A example with ip addresses:
from ipaddress import ip_address def ip_is_in_range(ip, start, end): start = ip_address(start) end = ip_address(end) ip = ip_address(ip) return start <= ip <= endWhat you've tried with the
range
object, works for integers.my_range = range(16, 31, 2) 18 in my_range 17 in my_range ... # And you can use the range object again and again. for i in my_range: for j in my_range: print(i, j)
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!