I have a list of
Comment has several properties, one of which is the
date the comment was posted. I've sorted this list by date and there is at least 1 comment per date in a range.
I would like to loop over
comments and for every date, create a new list of comments just for that day. However, the way I'm currently doing it feels very inefficient. Is there a more pythonic or efficient way to do this? (I've implemented a
daterange(start_date, end_date) generator function according to this answer):
comment_arrays =  #array of arrays for d in date_range(date(2015,1,1), date(2016,1,1)): day_comments =  for c in comments: if c.date == d: day_comments.append(c) else if c.date > d: comment_arrays.append(day_comments)