def dict_remove_key(d, k):
dd = dict()<EOL>for key, value in d.items():<EOL><INDENT>if not key == k:<EOL><INDENT>if isinstance(value, dict):<EOL><INDENT>dd[key] = dict_remove_key(value, k)<EOL><DEDENT>elif isinstance(value, list):<EOL><INDENT>dd[key] = [dict_remove_key(i, k) for i in value]<EOL><DEDENT>else:<EOL><INDENT>dd[key] = value<EOL><DEDENT><DEDENT><DEDENT>return dd<EOL>
Recursively remove a key from a dict
:param d: the dictionary
:param k: key which should be removed
:return: formatted dictionary