I have a dictionary, and would like to pass a part of it to a function, that part being given by a list (or tuple) of keys. Like so:
# the dictionary d = {1:
set intersection and dict comprehension can be used here
set intersection
dict comprehension
# the dictionary d = {1:2, 3:4, 5:6, 7:8} # the subset of keys I'm interested in l = (1,5) >>>{key:d[key] for key in set(l) & set(d)} {1: 2, 5: 6}