Timedelta constructor with string parameter
Felipe Menezes Machado
felipou at gmail.com
Tue Sep 23 13:15:43 EDT 2014
More information about the Python-list mailing list
Tue Sep 23 13:15:43 EDT 2014
- Previous message (by thread): Timedelta constructor with string parameter
- Next message (by thread): ANN: Python Meeting Düsseldorf - 30.09.2014
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 23, 2014 at 6:39 PM, Skip Montanaro <skip at pobox.com> wrote: > > On Tue, Sep 23, 2014 at 4:11 AM, <felipou at 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-list/attachments/20140923/d55cd739/attachment.html>
- Previous message (by thread): Timedelta constructor with string parameter
- Next message (by thread): ANN: Python Meeting Düsseldorf - 30.09.2014
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list