def rename(dct, mapping):
def _block(memo, key):<EOL><INDENT>if key in dct:<EOL><INDENT>memo[mapping[key]] = dct[key]<EOL>return memo<EOL><DEDENT>else:<EOL><INDENT>return memo<EOL><DEDENT><DEDENT>return reduce(_block, mapping, omit(dct, *mapping.keys()))<EOL>
Rename the keys of a dictionary with the given mapping

        >>> rename({"a": 1, "BBB": 2}, {"a": "AAA"})
        {'AAA': 1, 'BBB': 2}