I have a wrapper class for an object. I want it to apply all operations applied to it on the wrapped object, e.g wrapper+=a
would yield the same result as wrapped+=a
, for instance. I want to apply this for al开发者_如何转开发l operators. Any simple way to override all operators without overriding each one explicitly?
ActiveState Code: Recipe 496741: Object Proxying
No, sorry. Though you could write an interface (probably as a decorator or base class) that makes this easy, if you need to do it more than once. Or use one provided already. (Guess I was 40s too late.)
精彩评论