remove_dict_keys

pyhelpers.ops.remove_dict_keys(dictionary, *keys)[source]

Remove multiple keys from a dictionary.

Parameters:
  • dictionary (dict) – The dictionary from which keys should be removed.

  • keys – The keys to be removed from the dictionary.

Examples:

>>> from pyhelpers.ops import remove_dict_keys
>>> target_dict_ = {'k1': 'v1', 'k2': 'v2', 'k3': 'v3', 'k4': 'v4', 'k5': 'v5'}
>>> remove_dict_keys(target_dict_, 'k1', 'k3', 'k4')
>>> target_dict_
{'k2': 'v2', 'k5': 'v5'}