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

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Nagy László Zsolt <gandalf@shopzeus.com>
Newsgroups comp.lang.python
Subject Re: ANN: intervalset Was: Set type for datetime intervals
Date Mon, 4 Apr 2016 12:55:59 +0200
Lines 23
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>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de oOepJ0F/+Ka9c7FlFlVOIA3FzLq1TRryJnUxdTzhsb7Q==
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'subject:ANN': 0.07; 'todo:': 0.09; 'python': 0.10; '(also': 0.16; 'assumptions': 0.16; 'formatting,': 0.16; 'interval.': 0.16; 'none),': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'singleton': 0.16; 'subject:Was': 0.16; 'subject:type': 0.16; 'pascal': 0.22; 'code.': 0.23; 'header:In-Reply-To:1': 0.24; 'operators': 0.29; 'code': 0.30; 'probably': 0.31; 'skip:_ 10': 0.32; 'changed': 0.33; 'problem': 0.33; 'int': 0.33; 'ordered': 0.33; 'could': 0.35; 'fail': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'smaller': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'thank': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'easy': 0.60; 'your': 0.60; '&amp;': 0.61; 'personally': 0.61; 'limit': 0.65; 'subject:Set': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1459767355; bh=hoHFGCmuQvyGJkuM4/x+3w7/PsHX91+BhxR9tJYRtNs=; h=Subject:To:References:From:Date:In-Reply-To:From; b=KwjDiEUkTeuQlkc3zEKYlSx4kypBK4fJbLXSlh1V52OFHQezEQL1zDe5iUkfcaQk9 ygfe+qDj9ccBppl5BFSZXcf9gj/E+n3vBb+axp3BYZCfJJ87RLsDBKMWp/+9R+7ibG sDY2msdZffPE/u8e+MSeBs6R0l7npIhQLXlUYnLx143oOaBWPGzE5cj4dxXPLh4m/2 921KU5+QdWMU34XYb2zAvHIOz8WdFK/vYF5g3pE06SE1EkiFh6gpiO9EbNPvkH8XfK ODPAY/kZl9C83jTVqEjC/4xuFq0k/oXhfLxwo+WtOeZyonHLATod+d5num843ytlFd DdHrFfiP8juFw==
In-Reply-To <ndtgde$f30$1@ger.gmane.org>
X-Content-Filtered-By Mailman/MimeDel 2.1.21
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <5702483F.9040403@shopzeus.com>
X-Mailman-Original-References <56FE0625.5030901@shopzeus.com> <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com> <570213CB.8040101@shopzeus.com> <ndtgde$f30$1@ger.gmane.org>
Xref csiph.com comp.lang.python:106431

Show key headers only | 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