return self _wrapped(*args**kargsplus any others needed def accesscontrol(failif)def ondecorator(aclass)class oninstance(builtinsmixin)and use self _wrapped instead of self __wrapped def __getattr__(selfattr)def __setattr__(selfattrvalue)either one of these superclass mix-ins will be extraneous codebut must be implemented only onceand seem much more straightforward than the various metaclassor decorator-based tool approaches you'll find online that populate each proxy class with the requisite methods redundantly (see the class augmentation examples in for the principles behind such toolscoding variationsroutersdescriptorsautomation naturallyboth of the prior section' mixin superclasses might be improved with additional code changes we'll largely pass on hereexcept for two variations worth noting briefly firstcompare the following mutation of the first mix-in--which uses simpler coding structure but will incur an extra call per built-in operationmaking it slower (though perhaps not significantly so in proxy context)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 needed secondall the preceding built-in mix-in classes code each operator overloading method explicitlyand intercept the call issued for the operation with an alternative codingwe could instead generate methods from list of names mechanicallyand intercept only the attribute fetch preceding the call by creating class-level descriptors of the prior -as in the followingwhichlike the second mix-in alternativeassumes the proxied object is named _wrapped in the proxy instance itselfclass builtinsmixinclass proxydesc(object)def __init__(selfattrname)self attrname attrname def __get__(selfinstanceowner)return getattr(instance _wrappedself attrnamebuiltins ['add''str''getitem''call' decorators object for assume _wrapped plus any others