remove_dict_keys

pyhelpers.ops.remove_dict_keys(dictionary, *keys)

Remove multiple keys from a dictionary.

Parameters
  • dictionary (dict) – a dictionary

  • keys (any) – (a sequence of) any that can be the key of a 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'}