Dict-like behaviour

def has_key(self, key):
        """Dict-like behaviour"""
        try:
            if type(self.attrs) == dict:
                return key in self.attrs
            else:
                raise AttributeError    # if attrs is not a dict
        except AttributeError:          # if attrs doesnt exist
            raise NotImplementedError