(from_date, to_date=None, leap=timedelta(days=1))
return
>>> from_d = datetime(2010, 1, 1)
    >>> to_d = datetime(2010, 1, 5)
    >>> list(daterange(from_d, to_d))
    [datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 2, 0, 0), datetime.datetime(2010, 1, 3, 0, 0), datetime.datetime(2010, 1, 4, 0, 0), datetime.datetime(2010, 1, 5, 0, 0)]
>>> from_d = datetime(2010, 1, 1)
    >>> to_d = datetime(2010, 1, 5)
    >>> list(daterange(from_d, to_d))
    [datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 2, 0, 0), datetime.datetime(2010, 1, 3, 0, 0), datetime.datetime(2010, 1, 4, 0, 0), datetime.datetime(2010, 1, 5, 0, 0)]
>>> from_d = datetime ( 2010 1 1 ) >>> to_d = datetime ( 2010 1 5 ) >>> list ( daterange ( from_d to_d )) [ datetime . datetime ( 2010 1 1 0 0 ) datetime . datetime ( 2010 1 2 0 0 ) datetime . datetime ( 2010 1 3 0 0 ) datetime . datetime ( 2010 1 4 0 0 ) datetime . datetime ( 2010 1 5 0 0 ) ]
def daterange(from_date, to_date=None, leap=timedelta(days=1)):
    """
    >>> from_d = datetime(2010, 1, 1)
    >>> to_d = datetime(2010, 1, 5)
    >>> list(daterange(from_d, to_d))
    [datetime.datetime(2010, 1, 1, 0, 0), datetime.datetime(2010, 1, 2, 0, 0), datetime.datetime(2010, 1, 3, 0, 0), datetime.datetime(2010, 1, 4, 0, 0), datetime.datetime(2010, 1, 5, 0, 0)]
    """

    if to_date is None:
        if isinstance(from_date, datetime):
            to_date = datetime.utcnow()
        else:
            to_date = date.today()

    while from_date <= to_date:
        yield from_date
        from_date = from_date + leap
    return
def daterange ( from_date , to_date = None , leap = timedelta ( days = 1 ) ) : if to_date is None : if isinstance ( from_date , datetime ) : to_date = datetime . utcnow ( ) else : to_date = date . today ( ) while from_date <= to_date : yield from_date from_date = from_date + leap return