def copy(row, **renaming):
    """Create a copy of a dictionary, but allow renamings.

       Arguments:
       - row the dictionary to copy
       - **renaming allows renamings to be specified in the form
         newname=oldname meaning that in the result oldname will be
         renamed to newname.
    """
    if not renaming:
        return row.copy()

    tmp = row.copy()
    res = {}
    for k,v in renaming.items():
        res[k] = row[v]
        del tmp[v]
    res.update(tmp)
    return res