For those who don't like lists, this is my version:
def without_keys(d, *keys): dict(filter(lambda key_value: key_value[0] not in keys, d.items()))
Using:
>>> d={1:3, 5:7, 9:11, 13:15} >>> without_keys(d, 1, 5, 9) {13: 15} >>> without_keys(d, 13) {1: 3, 5: 7, 9: 11} >>> without_keys(d, *[5, 7]) {1: 3, 13: 15, 9: 11}
source share