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:
impor
If you're only creating the list for a few years then efficiency should not be a concern. Clarity of code is the most important aspect.
dates = [] date = datetime.date.today() while date.year < 2015: if date.day == 1: dates.append(date) date += datetime.timedelta(days=1)