datetime, calendar, time intervals

Michele Simionato michele.simionato at
Thu Jun 17 08:13:21 CEST 2004

Strangely enough, I never needed the datetime and calendar module
so I just looked at them today. I am surprised I don't easily find an
function such this:

import datetime

def interval(day, lastday, step): # not necessarely restricted to days
    while day < lastday:
        yield day
        day += step
firstday =, 05, 01)
lastday =, 06, 01)
oneday = datetime.timedelta(1)
for day in interval(firstday, lastday, oneday):
    print day

Did I overlook something? Has an iterator over time intervals been
taken in consideration for addition in the standard library? (or maybe
is already
there ...)
Also, the calendar module seems to be giving just the Unix "cal"
which is a  bit poor, I would have expected more ...

Just curious,

                          Michele Simionato

More information about the Python-list mailing list