#!/usr/local/bin/python3 from types import MethodType class C(object): def __init__(self): self.__setattr__ = MethodType(s, self) def s(self, key, value): if key == 'a': raise Error object.__setattr__(self, key, value) c = C() print()