[Marcus] > I'm looking for useful starting points, suggestions, and sample code, > to implement a calendar iterator. Simply, the iterator is seeded with > an initial calendar date, e.g., "03-12-2006", and then subsequent > calls to next return subsequent dates. The seed could be a standard > calendar/datetime object. > > > iter = calendarIterator("03-12-2006") > > print iter.next() > > 03-12-2006
import datetime, time def calendarIterator(start, fmt='%m-%d-%Y'): curr = datetime.date(*time.strptime(start, fmt)[:3]) one = datetime.timedelta(1) while 1: curr += one yield curr if __name__ == '__main__': iter = calendarIterator('3-12-2006') print iter.next() print iter.next() -- http://mail.python.org/mailman/listinfo/python-list