Hi, I noticed this when using the requests library in the response.elapsed object (type timedelta). Tested using the standard datetime library alone with the example displayed on https://docs.python.org/3/library/datetime.html#examples-of-usage-timedelta
It appears as though the timedelta object recursively adds its own
attributes (min, max, resolution) as further timedelta objects. I’m not sure how deep they go, but presumably hitting the recursion limit.
from datetime import timedelta999999999 days, 23:59:59.999999
year = timedelta(days=365)
print(year.max)
print(year.max.min.max.resolution.max.min)-999999999 days, 0:00:00
from datetime import timedelta
year = timedelta(days=365)
print(year.max)
print(year.max.min.max.resolution.max.min)
Hi, I noticed this when using the requests library in the response.elapsed object (type timedelta). Tested using the standard datetime library alone with the example displayed on https://docs.python.org/3/library/datetime.html#examples-of-usage-timedelta
It appears as though the timedelta object recursively adds its own
attributes (min, max, resolution) as further timedelta objects. I’m not sure how deep they go, but presumably hitting the recursion limit.
from datetime import timedelta
year = timedelta(days=365)
print(year.max)
999999999 days, 23:59:59.999999
print(year.max.min.max.resolution.max.min)
-999999999 days, 0:00:00
I’m using 3.10.3
<class 'datetime.timedelta'>from datetime import timedelta
year = timedelta(days=365)
type(year)
<class 'datetime.timedelta'>type(year.max)
Trueyear.max is year.max.max
<class 'datetime.timedelta'>type(year.min)
Trueyear.min is year.min.min
Hi, I noticed this when using the requests library in the response.elapsed >object (type timedelta). Tested using the standard datetime library alone >with the example displayed on >https://docs.python.org/3/library/datetime.html#examples-of-usage-timedelta
It appears as though the timedelta object recursively adds its own
attributes (min, max, resolution) as further timedelta objects. I’m not >sure how deep they go, but presumably hitting the recursion limit.
Thanks for the replies, I'm just trying to understand why this would be >useful?
E.g. why does max need a min/max/resolution, and why would these attributes >themselves need a min/max/resolution, etc, etc?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 235:19:35 |
Calls: | 6,624 |
Files: | 12,172 |
Messages: | 5,319,767 |