MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/259173_Groupby/recipe-259173.py:2–5  ·  view source on GitHub ↗
(self, seq, key=lambda x:x)

Source from the content-addressed store, hash-verified

1class groupby(dict):
2 def __init__(self, seq, key=lambda x:x):
3 for value in seq:
4 k = key(value)
5 self.setdefault(k, []).append(value)
6 __iter__ = dict.iteritems
7
8# -------------------------- Examples -----------------------------------

Callers

nothing calls this directly

Calls 3

keyFunction · 0.50
appendMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected