def private(*attributes)return accesscontrol(failif=(lambda attrattr in attributes)def public(*attributes)return accesscontrol(failif=(lambda attrattr not in attributes) 've also used one of our mix-in techniques to add some operator overloading method redefinitions to the wrapper classso that in it correctly delegates builtin operations to subject classes that use these methods as codedthe proxy is default classic class in that routes these through __getattr__ alreadybut in is new-style class that does not the mix-in used here requires listing such methods in public decoratorssee earlier for alternatives that do not (but that also do not allow built-ins to be made private)and expand this class as needed""file access_builtins py (from access _builtins pyroute some built-in operations back to proxy class __getattr__so they work the same in as direct by-name calls and ' default classic classes expand me as needed to include other __x__ names used by proxied objects ""class builtinsmixindef reroute(selfattr*args**kargs)return self __class__ __getattr__(selfattr)(*args**kargsdef __add__(selfother)return self reroute('__add__'otherdef __str__(self)return self reroute('__str__'def __getitem__(selfindex)return self reroute('__getitem__'indexdef __call__(self*args**kargs)return self reroute('__call__'*args**kargsplus any others used by wrapped objects in only here too split the self-test code off to separate fileso the decorator could be imported elsewhere without triggering the testsand without requiring __name__ test and indenting""fileaccess-test py test codeseparate file to allow decorator reuse ""import sys from access import privatepublic print(''test names are public if not private @private('age'class person decorators person private('age')(personperson oninstance with state