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


Groups > comp.lang.python > #78228

Re: Timedelta constructor with string parameter

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <felipou@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'yet.': 0.04; 'string': 0.09; 'function,': 0.09; 'subject:string': 0.09; 'to:addr:pobox.com': 0.09; 'to:addr:skip': 0.09; 'cc:addr:python- list': 0.11; 'changes': 0.15; '23,': 0.16; '32,': 0.16; 'accepts': 0.16; 'wrote:': 0.18; 'looked': 0.18; '>>>': 0.22; 'email addr:gmail.com&gt;': 0.22; 'handles': 0.22; 'cc:addr:python.org': 0.22; '&gt;&gt;&gt;': 0.24; 'parse': 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'cool,': 0.31; 'ones.': 0.31; 'sep': 0.31; 'skip:d 20': 0.34; "i'd": 0.34; 'subject:with': 0.35; 'created': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; "didn't": 0.36; 'thanks': 0.36; "i'll": 0.36; 'feed': 0.38; 'pm,': 0.38; 'little': 0.38; 'tell': 0.60; 'back': 0.62; 'more': 0.64; 'different': 0.65; 'study': 0.69; 'hood': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=Mjn2ebmIDfiJ+JJPvrb9laoh42X1RmGbkaYBLI2lCtc=; b=ib714+KbvG9BHvlEJeGPa6epr3U2nkLnEOwOEoyxyjjpHBuZFJvml3kmh94indpqHW j7l+TO+g4ZXMFksiyKgBUvCSvjil8UQNAMKMzjX9RacwTnexS+6kC6HxmV5q5/R75Lqc f5GfsQyeXDj9W3OAP6aFfYqeP+KF64UaX50VJEYb6NcBmPD5IzhEXkx7Fq0EKcyB/3ER jyIfW6WBUvDZPKwfzxl+1500t4YxVn3cNdVGmYsHN70Burc/dIZHzY48IGvdN6OOISnH 64qstUVw6s0bSQle6ESThgNogd2rZ1c5zNF+8lLZG2p1UarBoSmiMkr2Gcpny0UUTQYP VLdQ==
X-Received by 10.180.84.193 with SMTP id b1mr25044793wiz.40.1411492563207; Tue, 23 Sep 2014 10:16:03 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <CANc-5Uyna==N5DyU5188TAaRw0FCv2Hkhuhd0C6LT-_foVai6g@mail.gmail.com>
References <a63a4890-eeb3-495c-bb81-3c1bbb85bff2@googlegroups.com> <CANc-5Uyna==N5DyU5188TAaRw0FCv2Hkhuhd0C6LT-_foVai6g@mail.gmail.com>
From Felipe Menezes Machado <felipou@gmail.com>
Date Tue, 23 Sep 2014 19:15:43 +0200
Subject Re: Timedelta constructor with string parameter
To Skip Montanaro <skip@pobox.com>
Content-Type multipart/alternative; boundary=f46d04374501d54c790503beb83d
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.14275.1411492570.18130.python-list@python.org> (permalink)
Lines 68
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411492570 news.xs4all.nl 2835 [2001:888:2000:d::a6]:49214
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78228

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Sep 23, 2014 at 6:39 PM, Skip Montanaro <skip@pobox.com> wrote:

>
> On Tue, Sep 23, 2014 at 4:11 AM, <felipou@gmail.com> wrote:
>
>> I created some code recently to parse a string and create a timedelta
>> from it.
>
>
> Interesting. I notice that dateutil.parser.parse already understands you
> notation:
>
> >>> x = dateutil.parser.parse("5h32m15s")
> >>> x
> datetime.datetime(2014, 9, 23, 5, 32, 15)
>
> All that would be necessary is some way to tell it to generate a timedelta
> instead of a datetime. Might be better to feed changes back to the dateutil
> package maintainers.
>
>
Cool, thanks for the tip, I didn't know dateutil yet.

I looked at the code for the dateutil.parser.parse function, and under the
hood it is so much more than my function does. It accepts many different
formats, and also handles timezones. So I'd have to study it a little to
think of a way for it to generate timedelta objects instead of datetime
ones. But I'll definitely keep that in mind!

Felipe

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


Thread

Timedelta constructor with string parameter felipou@gmail.com - 2014-09-23 02:11 -0700
  Re: Timedelta constructor with string parameter Skip Montanaro <skip@pobox.com> - 2014-09-23 11:39 -0500
  Re: Timedelta constructor with string parameter Felipe Menezes Machado <felipou@gmail.com> - 2014-09-23 19:15 +0200

csiph-web