首页 > 编程语言 > 详细

python重写运算符

时间:2020-05-21 19:54:04      阅读:62      评论:0      收藏:0      [点我收藏+]
class Operator(object):
    def __init__(self, task_id):
        self.task_id = task_id

    def __rshift__(self, other):
        print(%s>>%s % (self.task_id, other.task_id))
        return other


if __name__ == __main__:
    aa = Operator(aa)
    bb = Operator(bb)
    cc = Operator(cc)
    aa >> bb >> cc

 

python重写运算符

原文:https://www.cnblogs.com/wangbin2188/p/12932775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!