Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Selik Newsgroups: comp.lang.python Subject: Re: Set type for datetime intervals Date: Fri, 01 Apr 2016 20:32:43 +0000 Lines: 28 Message-ID: References: <56FE0625.5030901@shopzeus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de +FXzpAa3NEDzaif4pKF67wHIlWWiOVByMdze0N+nNCjQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'url:pypi': 0.03; 'builtin': 0.07; 'implements': 0.07; 'def': 0.13; '2016': 0.16; 'pypi?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:type': 0.16; 'url:submit': 0.16; 'wrote:': 0.16; 'email addr:gmail.com>': 0.18; 'library': 0.20; 'to:name:python- list@python.org': 0.20; 'to:2**1': 0.21; 'mixed': 0.22; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'resolution': 0.28; 'anyone': 0.32; 'url:python': 0.33; 'michael': 0.33; 'received:google.com': 0.35; 'ones': 0.35; 'url:%3a': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'url:action': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'received:209.85.220': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'tasks.': 0.66; 'url:search': 0.83; 'nagy': 0.84; 'stop,': 0.84; 'subject:Set': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=KTzPZvmH1GOeFz/WKvz8JGWhuqePbzKhPs5SQ+FwOG0=; b=aMOMUmpXfSFTYY+SETi8ZWd1sfUkuMLKMJoSg4ASFH4/PukcP5SKHB/p3nWVBhqxve KG8zPxvazljakXGuVHBeik65kaSY5fDozkiTZn8/oEefqDdp8UpuN5bWhFp9JPJSZW+V kBbffmokGqCDoL2IYne9y14/86/vvXiLj4LBz1Ik8cDySmDCzB7frUcK634f0X+V4r4S fNIep0QFSFf3y4ZIje0ry8ONxqOwv1v7skkwR5xrXbxVsyilzu8JYjAVOyUZujmrcTT7 zUzhbAt/n3eNzi4UMsbz/GwH9ZkGUoPE2S1s1CEGPhD9p8+GQ/0iQPRAx3xHlSYSq2by w67Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=KTzPZvmH1GOeFz/WKvz8JGWhuqePbzKhPs5SQ+FwOG0=; b=V7LKo3GWfhxgOCV84VyhjwRbVJ40hLUb9Ep+4NpuM0oEH9S4fZnq1iDV9tinF68jaL UTycjX5DtSkPi0pI+IKPoh5IVsQsmWi42yPjdS5cEXpppwDZlWR81sVLJhg/riQTLt7p Ig5OQokZMRcf1D6JiutbIPLmwH5QovG4jY0jx0m0AeOjxVNDvZI3YQX6liXqTjoQH4zX xzLJegL0ZcQpKsHu1WYW8JeSaaJ5XQIGMy/yn1mgA9MY5mtjutKEqrPepggOw09ZtdR5 HvKb/3PFNxxeuKf9OpFOX7SP9xYZxHZVIyfihgomRJ5lLCkRSi56Zx4E64P1DRFr0jdZ aPvw== X-Gm-Message-State: AD7BkJKo7QvwefUimXbOzC98tFWjChr+fiiZVYbrSSiQiQTIaBy4HBRTSU6O8ur+He+JnVD7l08mylHyS+dF0A== X-Received: by 10.55.79.17 with SMTP id d17mr20797912qkb.56.1459542772323; Fri, 01 Apr 2016 13:32:52 -0700 (PDT) In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:106256 Whoops, I mixed up tasks. Here's what I meant: def interval(start, stop, precision=3D60): a, b =3D start.timestamp(), stop.timestamp() return set(range(a, b, precision)) On Fri, Apr 1, 2016 at 4:31 PM Michael Selik wrote: > On Fri, Apr 1, 2016 at 1:32 AM Nagy L=C3=A1szl=C3=B3 Zsolt > wrote: > >> Does anyone know a library that already implements these functions? >> > > What do you not like about the ones on PyPI? > https://pypi.python.org/pypi?%3Aaction=3Dsearch&term=3Dinterval&submit=3D= search > > Depending on the resolution you want, you might be able to use builtin > sets for everything. > > def interval(start, stop, precision=3D60): > a =3D round(start.timestamp(), precision) > b =3D round(stop.timestamp(), precision) > return set(range(a, b, precision)) >