find nearest time in datetime list

Tim Chase python.list at
Wed Jan 30 15:06:28 CET 2008

Boris Borcic wrote:
> min(DTlist,key=lambda date : abs(dt-date))

In Python2.4:

   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   TypeError: min() takes no keyword arguments

Looks like min() only started taking keywords (key) from 
Python2.5 forward.

But the min() solution is good if you're running 2.5


More information about the Python-list mailing list