class Watcher(object):
    """Watches entries added to a MyDict (dictionary).  key_found() is called
    when an item is added whose key matches one of elements in keys.
    """

def __init__(self, *keys):
    self.keys = keys

def key_found(self, key, value):
    print(key, value)


class MyDict(dict):

    def __init__(self, *args, **kwargs):
        self.watcher = kwargs.pop('watcher')
super(MyDict, self).__init__(*args, **kwargs)

def __setitem__(self, key, value):
    super(MyDict, self).__setitem__(key, value)
if key in self.watcher.keys:
    self.watcher.key_found(key, value)
watcher = Watcher('k1', 'k2', 'k3')
d = MyDict(watcher=watcher)
d['a'] = 1
d['b'] = 2
d['k1'] = 'k1 value'
Pythonic way of polling a dictionary - using the key's value once it exists