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

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: get the min date from a list
Date 2014-08-10 08:46 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-C9CF9E.08465310082014@news.panix.com> (permalink)
References <53E71BCB.7060307@gmail.com> <mailman.12816.1407668534.18130.python-list@python.org>

Show all headers | 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