ANN: intervalset Was: Set type for datetime intervals

Nagy László Zsolt gandalf at shopzeus.com
Mon Apr 4 06:55:59 EDT 2016


> Why do you limit the intervals to datetime? Are there any assumptions in 
> your code that would make it fail with int values?

Just one. The empty interval is a singleton and I want it to be smaller
than any other interval.

UTC_ZERO = datetime.datetime.utcfromtimestamp(0)
EMPTY_INTERVAL = Interval(UTC_ZERO, UTC_ZERO) # TODO: how generalize
this for any ordered type?

Probably I could use Interval(None, None), and refactor my code.

The other problem would be __str__ and formatting, but that is easy to
generalize.

>
> Personally I would use & | instead of * + -- Python is not Pascal ;)
Operators changed to what you have suggested. (Also added ^ and
__contains__)

Thank you!




More information about the Python-list mailing list