get the min date from a list
Roy Smith
roy at panix.com
Sun Aug 10 08:46:53 EDT 2014
In article <mailman.12816.1407668534.18130.python-list at python.org>,
Dave Angel <davea at 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).
More information about the Python-list
mailing list