def sections(self): sec = {} sections = [] for sett in ordered_settings(): s = sett.section if s not in sec: sections.append(s) sec[s] = [sett] else: sec[s].append(sett) for s in sections: yield s, sec[s]