What\'s the best way, both aesthetically and from a performance perspective, to split a list of items into multiple lists based on a conditional? The equivalent of:
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