def get_last_week_range ( weekday_start = "Sunday" ) : today = date . today ( ) # Get the first day of the past complete week. start_of_week = snap_to_beginning_of_week ( today , weekday_start ) - timedelta ( weeks = 1 ) end_of_week = start_of_week + timedelta ( days = 6 ) return ( start_of_week , end_of_week )
using datetime to get the last 7 dates of a week given a date in python
Gets the date for the first and the last day of the previous complete week .
def get_last_week_range(weekday_start="Sunday"):
    """ Gets the date for the first and the last day of the previous complete week.

    :param weekday_start: Either "Monday" or "Sunday", indicating the first day of the week.
    :returns: A tuple containing two date objects, for the first and the last day of the week
              respectively.
    """
    today = date.today()
    # Get the first day of the past complete week.
    start_of_week = snap_to_beginning_of_week(today, weekday_start) - timedelta(weeks=1)
    end_of_week = start_of_week + timedelta(days=6)
    return (start_of_week, end_of_week)