I don't think there is a method in the Python library, but you can easily create it yourself using the datetime module:
from datetime import date, datetime, timedelta def datespan(startDate, endDate, delta=timedelta(days=1)): currentDate = startDate while currentDate < endDate: yield currentDate currentDate += delta
Then you can use it as follows:
>>> for day in datespan(date(2007, 3, 30), date(2007, 4, 3), >>> delta=timedelta(days=1)): >>> print day 2007-03-30 2007-03-31 2007-04-01 2007-04-02
Or if you want to reduce your delta:
>>> for timestamp in datespan(datetime(2007, 3, 30, 15, 30), >>> datetime(2007, 3, 30, 18, 35), >>> delta=timedelta(hours=1)): >>> print timestamp 2007-03-30 15:30:00 2007-03-30 16:30:00 2007-03-30 17:30:00 2007-03-30 18:30:00
JinX Sep 30 '08 at 15:50 2008-09-30 15:50
source share