I want to create a list of dates, starting with today, and going back an arbitrary number of days, say, in my example 100 days. Is there a better way to do it than this?
import datetime a = datetime.datetime.today() numdays = 100 dateList =  for x in range (0, numdays): dateList.append(a - datetime.timedelta(days = x)) print dateList
base = datetime.datetime.today() date_list = [base - datetime.timedelta(days=x) for x in range(numdays)]
Pandas is great for time series in general, and has direct support for date ranges.
import pandas as pd datelist = pd.date_range(pd.datetime.today(), periods=100).tolist()
It also has lots of options to make life easier. For example if you only wanted weekdays, you would just swap in
In addition it fully supports pytz timezones and can smoothly span spring/autumn DST shifts.
EDIT by OP:
If you need actual python datetimes, as opposed to Pandas timestamps:
pd.date_range(end = pd.datetime.today(), periods = 100).to_pydatetime().tolist()
This uses the "end" parameter to match the original question, but if you want descending dates: