class Operator(object):
    def __init__(self, task_id):
        self.task_id = task_id

    def __rshift__(self, other):
        if isinstance(other, Operator):
            print('%s=>%s' % (self.task_id, other.task_id))
        elif isinstance(other, list):
            for item in other:
                print('%s=>%s' % (self.task_id, item.task_id))
        return other

    def __lshift__(self, other):
        if isinstance(other, Operator):
            print('%s<=%s' % (self.task_id, other.task_id))
        elif isinstance(other, list):
            for item in other:
                print('%s<=%s' % (self.task_id, item.task_id))
        return other

    def __rrshift__(self, other):
        self.__lshift__(other)
        return self

    def __rlshift__(self, other):
        self.__rshift__(other)
        return self


if __name__ == '__main__':
    a = Operator('a')
    b = Operator('b')
    c = Operator('c')
    d = Operator('d')
    a >> [b, c] >> d

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-10-20
  • 2021-11-25
  • 2021-08-18
  • 2022-12-23
相关资源
相似解决方案