1

I have a dictionary: d

Is there a way to fetch multiple values of keys from dictionary.

Example:

d = {1:1, 2:2, 4:4}
keys = [1,2,3]
k_v_pairs = multi_key_fetch(d, keys) --> returns {1:1, 2:2}

I am hoping not to loop thru the dictionary and search one key at a time? So, was wondering if there is a dictionary implementation in python, which helps in retrieving multiple keys in one shot from a dictionary and also tells us which keys are "hit" and "missed"?

frazman
  • 32,081
  • 75
  • 184
  • 269

0 Answers0