Better than a single line of code? What is it that you are looking for? If you dates are consistent you can do:
year, month, day=map(int, d.split('-')) but I'm not sure it is "better". I guess it depends on what you want to do with them after parsing. -Larry Bates Kalle Anke wrote: > I want to parse a date string, for example '2005-09-23', and since I haven't > done this before I would like to ask what is the best way to do it. > > I've looked around and the dateutil seems to be what most people use, but > unfortunately I only get an empty file when I try to download it. I also > tried the standard modules and ended up with this > > import datetime > from time import strptime > > d = '2005-09-23' > w = strptime(d,'%Y-%m-%d') > print datetime.date( w[0], w[1], w[2] ) > > But I suspect there is a better way to do it?? > -- http://mail.python.org/mailman/listinfo/python-list