datetime.iterdate
Michele Simionato
michele.simionato at gmail.com
Mon Jul 12 03:51:12 EDT 2004
"Robert Brewer" <fumanchu at amor.org> wrote in message news:<mailman.236.1089594533.5135.python-list at python.org>...
> Anyone else tired of typing date-addition logic when iterating? It would
> be nice if the datetime package had something like:
>
> def iterdates(first, last):
> for day in range((last - first).days + 1):
> yield first + datetime.timedelta(day)
>
> ...notice the inclusive boundaries (i.e. last gets returned). This
> simple construct would make ugly date loops a lot cleaner:
>
> for day in datetime.iterdates(first date, last date):
> do something with(day)
>
>
>
> Robert Brewer
> MIS
> Amor Ministries
> fumanchu at amor.org
I actually asked the same four weeks ago (thread "datetime, calendar,
time intervals") since it is one of the first things I would have
expected to
find in the datetime module.
I don't see as a problem to add functions to modules (as opposed to
add new builtins which requires a lot of care). Is good to have even
simple functions in modules, if they are common, since you have the
advantage to have a stardard names for standard things, such as
interating
on time intervals. Of course, there should be the possibily of passing
a generic time step.
Michele Simionato
More information about the Python-list
mailing list