The dateutil parser might be already there if you are in OS-X. If it not it is easy to install.

Assuming that your dates are in the date_strings array and that you are not American you just have to

from dateutil.parser import parse as parse_date dates = [parse_date(ds, dayfirst= True ).date() for ds in date_strings]

This will take care of dates of the form "13-04-2010", and also "23/5/2011". It will also take care of dates the way they should always be written, "2011-03-28". If you are American you might want to remove the dayfirst=True .

We've come to take these things for granted, but I think you'll agree with me that this code is a beautiful thing.

First, it's already there or easy to install, so you'll use the same thing for all your programs. I've just checked my Common Lisp projects and I've found three different parse-date functions; they tend to look like

( defun parse-date (date) "Date is YYYY-MM-DD, returns universal time." ( unless (string-equal date "" ) (apply #'encode-universal-time (append '(0 0 0) (nreverse (mapcar #'parse-integer (ppcre:split "-" date)))))))

which is OK, but it requires the (great) regular expression library to be part of your project, and it fails for separators different than "-". And it is one of three. Sure I could have made a library and always use the same function, but designing good libraries is hard, and I've never bothered for this.