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


Groups > comp.lang.python > #75982

Re: get the min date from a list

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!roy
From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: get the min date from a list
Date Sun, 10 Aug 2014 08:46:53 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Lines 15
Message-ID <roy-C9CF9E.08465310082014@news.panix.com> (permalink)
References <53E71BCB.7060307@gmail.com> <mailman.12816.1407668534.18130.python-list@python.org>
NNTP-Posting-Host localhost
X-Trace reader1.panix.com 1407674814 6169 127.0.0.1 (10 Aug 2014 12:46:54 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Sun, 10 Aug 2014 12:46:54 +0000 (UTC)
User-Agent MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)
Xref csiph.com comp.lang.python:75982

Show key headers only | View raw


In article <mailman.12816.1407668534.18130.python-list@python.org>,
 Dave Angel <davea@davea.name> wrote:

> Your simplest answer is probably to write a function that converts
>  a string like you have into a datetime object, say call it
>  converter (). Then after testing it, you call
> 
> min (dates, key = converter)

Wow, after all these years, I didn't know min() took a key argument.  Of 
course, it makes sense, but I just never noticed that before.  Thanks!

And for the OP, for the converter function, I would suggest 
dateutil.parse.parser(), from the python-dateutil module 
(https://labix.org/python-dateutil).

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


Thread

Re:get the min date from a list Dave Angel <davea@davea.name> - 2014-08-10 07:02 -0400
  Re: get the min date from a list Roy Smith <roy@panix.com> - 2014-08-10 08:46 -0400

csiph-web