Ejemplo n.º 1
0
def cmp_fun():
    a, b = 5, 3
    print (operator.lt(a,b))
    #True Same as a<b.
    print (operator.le(a, b))
    # False
    print (operator.eq(a,b))
    # False
    print (operator.ne(a,b))    
    #TRUE
    print(operator.ge(a,b))
    #False Same as a>=b
    print (operator.gt(a, b))
    # True
    print (operator.__lt__(a, b))
    #TRUE
    print (operator.__le__(a, b))
    #TRUE
    print (operator.__ne__(a, b))
    #TRUE Same as a<b.
    print (operator.__ge__(a, b))    
    #FALSE
    print (operator.__gt__(a, b))
    #FALSE
    print (operator.__eq__(a, b))
Ejemplo n.º 2
0
 def specialcases(x):
     operator.lt(x,3)
     operator.le(x,3)
     operator.eq(x,3)
     operator.ne(x,3)
     operator.gt(x,3)
     operator.ge(x,3)
     is_operator(x,3)
     operator.__lt__(x,3)
     operator.__le__(x,3)
     operator.__eq__(x,3)
     operator.__ne__(x,3)
     operator.__gt__(x,3)
     operator.__ge__(x,3)
     # the following ones are constant-folded
     operator.eq(2,3)
     operator.__gt__(2,3)
Ejemplo n.º 3
0
 def specialcases(x):
     operator.lt(x, 3)
     operator.le(x, 3)
     operator.eq(x, 3)
     operator.ne(x, 3)
     operator.gt(x, 3)
     operator.ge(x, 3)
     is_operator(x, 3)
     operator.__lt__(x, 3)
     operator.__le__(x, 3)
     operator.__eq__(x, 3)
     operator.__ne__(x, 3)
     operator.__gt__(x, 3)
     operator.__ge__(x, 3)
     operator.xor(x, 3)
     # the following ones are constant-folded
     operator.eq(2, 3)
     operator.__gt__(2, 3)
Ejemplo n.º 4
0
 def __ne__(self, value):
     return operator.__ne__(self._tensor, value)
Ejemplo n.º 5
0
@Time    : 2020/6/20 14:08
@Software: PyCharm
@File    : operator_learn.py
'''

import operator
a = 6
b = 7
operator.lt(a, b)  #less than小于

operator.le(a, b)  #lessthan or equal to小于等于

operator.eq(a, b)  #equal to等于

operator.ne(a, b)  #not equalto不等于

operator.ge(a, b)  #greaterand equal to大于等于

operator.gt(a, b)  #greater大于

operator.__le__(a, b)

operator.__lt__(a, b)

operator.__eq__(a, b)

operator.__ne__(a, b)

print(operator.__ge__(a, b))

operator.__gt__(a, b)
Ejemplo n.º 6
0
def not_equals(*args):
    assert len(args) == 2, "Expected 2 arguments, got %d" % len(args)
    return op.__ne__(*args)
Ejemplo n.º 7
0
 def __ne__(self, other):
     """self != other"""
     return __ne__(get_wrapped_object(self), get_wrapped_object(other))
Ejemplo n.º 8
0
 def update_event(self, inp=-1):
     self.set_output_val(0, operator.__ne__(self.input(0), self.input(1)))
Ejemplo n.º 9
0
matmul = spice(lambda x, y: operator.matmul(y, x), name='matmul')
__matmul__ = spice(lambda x, y: operator.__matmul__(y, x), name='__matmul__')

# reversed
mod = spice(lambda x, y: operator.mod(y, x), name='mod')
__mod__ = spice(lambda x, y: operator.__mod__(y, x), name='__mod__')

mul = spice(lambda x, y: operator.mul(x, y),
            name='mul',
            doc=operator.mul.__doc__)
__mul__ = spice(lambda x, y: operator.__mul__(x, y),
                name='__mul__',
                doc=operator.mul.__doc__)

ne = spice(lambda x, y: operator.ne(x, y), name='ne', doc=operator.ne.__doc__)
__ne__ = spice(lambda x, y: operator.__ne__(x, y),
               name='__ne__',
               doc=operator.ne.__doc__)

or_ = spice(lambda x, y: operator.or_(x, y),
            name='or_',
            doc=operator.or_.__doc__)
__or__ = spice(lambda x, y: operator.__or__(x, y),
               name='__or__',
               doc=operator.or_.__doc__)

pos = spice(lambda x, y: operator.pos(x, y),
            name='pos',
            doc=operator.pos.__doc__)

#reversed