If you insist on clever, you could take Winden's solution and just a bit spurious cleverness:
def splay(l, f, d=None): d = d or {} for x in l: d.setdefault(f(x), []).append(x) return d
If you insist on clever, you could take Winden's solution and just a bit spurious cleverness:
def splay(l, f, d=None): d = d or {} for x in l: d.setdefault(f(x), []).append(x) return d