I really love shrinking my code into as few lines as possible. I have the code below and I been trying to get it into one line, if anyone can advise, i would appreciate it.
list_choices = {}
if_changed = ''
for i in obj:
if if_changed!=i.area.region.id:
if_changed = i.area.region.id
list_choices.setdefault(if_changed, [])
list_choices[if_changed].append([i.id, i.name])
i.area.region.id
changes is not necessary. If it were, one could useitertools.groupby
rather than this technique.