import timeimport datetime
# use mktime to step by one day# end - the last day, numdays - count of days to step backdef gen_dates_list(end, numdays):start = end - datetime.timedelta(days=numdays+1)end = int(time.mktime(end.timetuple()))start = int(time.mktime(start.timetuple()))# 86400 s = 1 dayreturn xrange(start, end, 86400)
# if you need reverse the list of datesfor dt in reversed(gen_dates_list(datetime.datetime.today(), 100)):print datetime.datetime.fromtimestamp(dt).date()