开发者

Override all operators in python

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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜