I am trying find an efficient way of creating a list of dates only including the first day of the month for a given period. Something like this but better:
This is the same as @Andrew's answer, but much faster:
dates = []
date = datetime.date.today()
while date.year < 2015:
if date.day == 1:
dates.append(date)
# I added the following line:
date += datetime.timedelta(days=27)
date += datetime.timedelta(days=1)