Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'subject:string': 0.09; 'cc:addr:python-list': 0.11; 'changes': 0.15; '23,': 0.16; '32,': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; '>>>': 0.24; 'parse': 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'sep': 0.31; 'skip:d 20': 0.34; 'subject:with': 0.35; 'created': 0.35; 'received:google.com': 0.35; 'feed': 0.38; 'tell': 0.60; 'back': 0.62; 'to:addr:gmail.com': 0.65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=qSaJK/JF9PgIePWni5grMV07x88hOCd/gCPliRbezFs=; b=vbgYkBpKC2nhCdIaUyDF9gvS9NXlMPofXDx4LomnNmdlhvjyWib2teXHdembRm0rJC Bj/CwUVGC5rB13+/2SXKkQigDzvigz0JPmuNZ5eipt6ZR8m5FCx9AG2iz3b5Rxw6Dvlg 4vR8sKQ+p2rixtHVsP3rBdNn1DISOtUmCUWrxRrodzYcCEuf0QHaXnKqn81h+ILr7vlG gDAne1ILUBLcpjEJWZAIXpfwxIzUnxdo7NXX7OwnU+eNjhungGLnA/QAvhsIxt+UMnKT OzTWLcEGZsM5m3SQH/Olf0bgec/6CIYWXOMvaRt/uGjWDifP38wCKB9Y/K+jhqdFkKBm +UQQ== MIME-Version: 1.0 X-Received: by 10.50.164.202 with SMTP id ys10mr4975344igb.6.1411490389933; Tue, 23 Sep 2014 09:39:49 -0700 (PDT) Sender: skip.montanaro@gmail.com In-Reply-To: References: Date: Tue, 23 Sep 2014 11:39:49 -0500 X-Google-Sender-Auth: mv557-hAjHFuG61BArHFpUpT238 Subject: Re: Timedelta constructor with string parameter From: Skip Montanaro To: felipou@gmail.com Content-Type: multipart/alternative; boundary=089e014949064bcf260503be3781 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411490392 news.xs4all.nl 2961 [2001:888:2000:d::a6]:32880 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78225 --089e014949064bcf260503be3781 Content-Type: text/plain; charset=UTF-8 On Tue, Sep 23, 2014 at 4:11 AM, 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. Skip --089e014949064bcf260503be3781 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Tue, Sep 23, 2014 at 4:11 AM, <felipou@gmail.com> wrote:=
I created some code recently to parse a string and cre= ate a timedelta from it.

Interesting. I notice that d= ateutil.parser.parse already understands you notation:

>>> x =3D dateutil.parser.parse("5h32m15s")
>>> x
datetim= e.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 da= tetime. Might be better to feed changes back to the dateutil package mainta= iners.

Skip

--089e014949064bcf260503be3781--