def frozen(set):
    "Raise an error when trying to set an undeclared name."
    def set_attr(self,name,value):
        if hasattr(self,name):
            set(self,name,value) 
        else:
            raise AttributeError("You cannot add attributes to %s" % self)
    return set_attr
Raise an error when trying to set an undeclared name.
recipes/Python/252158_How_to_freeze_Python_classes/recipe-252158.py