Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106431

Re: ANN: intervalset Was: Set type for datetime intervals

From Nagy László Zsolt <gandalf@shopzeus.com>
Newsgroups comp.lang.python
Subject Re: ANN: intervalset Was: Set type for datetime intervals
Date 2016-04-04 12:55 +0200
Message-ID <mailman.9.1459767357.32530.python-list@python.org> (permalink)
References <56FE0625.5030901@shopzeus.com> <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com> <570213CB.8040101@shopzeus.com> <ndtgde$f30$1@ger.gmane.org> <5702483F.9040403@shopzeus.com>

Show all headers | View raw


> 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!

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: ANN: intervalset Was: Set type for datetime intervals Nagy László Zsolt <gandalf@shopzeus.com> - 2016-04-04 12:55 +0200

csiph-web