def group_by_year(objs): entries = {} for obj in objs: year = obj.date.strftime('%Y') try: entries[year].append(obj) except: entries[year] = [obj] return entries def filter_by_attr(objs, attr): return filter(lambda x: hasattr(x,attr), objs) def filter_by_path(objs, value): return filter(lambda page: page.path.startswith(value), objs) filters = [filter_by_attr, filter_by_path, group_by_year]