下のような処理を書きたいんですが、
lambda x: x とか result[k] = result.get(k, 0) + 1 あたりはもっといい書き方ないですかね。

def count_by(iterable, func = lambda x: x):
  result = {}
  for e in iterable:
    k = func(e)
    result[k] = result.get(k, 0) + 1
  return result