def __str__(self):
        # When an infix operator is left-associative, we need to append parens
        # when rhs has the same priority
        #  e.g. x << (y << z) != x << y << z

        left = _repr(self.lhs)
        if isinstance(self.lhs, Expr) and (
                self.priority > self.lhs.priority or
                (self.right_associative and
                 self.priority == self.lhs.priority)):
            left = '(' + left + ')'

        right = _repr(self.rhs)
        if isinstance(self.rhs, Expr) and (
                self.priority > self.rhs.priority or
                (not self.right_associative and
                 self.priority == self.rhs.priority)):
            right = '(' + right + ')'

        return '{0} {2} {1}'.format(left, right, self.exp)
dataset/ETHPy150Open pfnet/chainer/chainer/utils/type_check.py/BinaryOperator.__str__/original