Hi guys,

I often run into the problem when I need to systematically rename a bunch of keys in a table. For example, a JSON API returns an object where I need to map "Media Cost" to "adjusted_partner_cost", "Impressions" to "bid_count", etc. One way of doing this is:

key_map = {
    'Media Cost': 'adjusted_partner_cost',
    'Impressions': 'bids_won',
    'Day': 'date'
}

mykeys = {}
for k, v in dict_from_elsewhere.items():
  if k in key_map:
    ret[key_map[k]] = v
  else:
    ret[k] = dict_from_elsewhere[k]

I would love to be able to instead say something like:

mykeys = defaultdict(lambda x:x, {
    'Media Cost': 'adjusted_partner_cost',
    'Impressions': 'bids_won',
    'Day': 'date'
})

But default functions don't take parameters. Ideas?

- Andrey