isodate.duration.Duration: Duration comparison is inconsistent?

◇◆丶佛笑我妖孽 提交于 2019-12-24 21:05:51

问题


This is copied straight out of my console:

>>> import isodate
>>> import datetime

First statements are as expected. 1 month duration not longer than 10 years duration.

>>> duration = isodate.parse_duration("P1M")
>>> duration > isodate.duration.Duration(0, 0, 0, years=10, months=0)
False

But then I get 1 month duration is longer than 10 years duration all of a sudden.

>>> duration = isodate.parse_duration("P1M")
>>> isinstance(duration, isodate.Duration)
True
>>> duration > isodate.duration.Duration(0, 0, 0, years=10, months=0)
True
>>> duration
isodate.duration.Duration(0, 0, 0, years=0, months=1)

What is happening here that I don't understand.

来源:https://stackoverflow.com/questions/52332509/isodate-duration-duration-duration-comparison-is-inconsistent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!