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))
Beispiel #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)
Beispiel #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)
Beispiel #4
0
def call_const_le(self: jit.Judge, *args: jit.AbsVal):
    if len(args) != 2:
        return NotImplemented
    a, b = args
    if a.is_literal() and b.is_literal():
        const = jit.S(operator.__le__(a.base, b.base))
        ret_types = (jit.S(type(const.base)), )
        return jit.CallSpec(const, const, ret_types)

    return self.spec(jit.S(operator.__le__), "__call__", list(args))
Beispiel #5
0
def operations_to_functions(operation, a, b):
    if operation == ">=":
        return operator.__ge__(a, b)
    if operation == "<=":
        return operator.__le__(a, b)
    if operation == "=":
        return operator.__eq__(a, b)
    if operation == ">":
        return operator.__gt__(a, b)
    if operation == "<":
        return operator.__lt__(a, b)
Beispiel #6
0
 def __le__(self, value):
     return operator.__le__(self._tensor, value)
Beispiel #7
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)
Beispiel #8
0
import os
""" Declare variable """
logs = '/Users/dimzrio/PycharmProjects/rotate-streaming/mysql-slowtest.log'
timer = 1  # in minutes
""" Open stream to file """
steam = open(logs,
             mode='r',
             buffering=1,
             encoding=None,
             errors=None,
             newline=None,
             closefd=True)
""" Read buffer from stream """
while True:
    rotate_schedule = datetime.now() + timedelta(minutes=timer)
    ext = rotate_schedule.strftime('%Y-%m-%d_%H%M')
    filename = '{0}-{1}'.format(logs, ext)
    rotate_file = open(filename, 'w')
    while True:
        time_now = datetime.now()
        if operator.__le__(time_now, rotate_schedule):
            content = steam.read()
            if content is not None:
                rotate_file.write(content)
            time.sleep(0.5)
        else:
            break
    rotate_file.close()
    """ Remove if file is empty """
    os.remove(filename) if os.stat(filename).st_size == 0 else print(
        '[+] Rotate successfully..!!!')
Beispiel #9
0
 def __le__(self, other):
     """self <= other"""
     return __le__(get_wrapped_object(self), get_wrapped_object(other))
Beispiel #10
0
 def update_event(self, inp=-1):
     self.set_output_val(0, operator.__le__(self.input(0), self.input(1)))
Beispiel #11
0
gt = spice(lambda x, y: operator.gt(y, x), name='gt')
__gt__ = spice(lambda x, y: operator.__gt__(y, x))

indexOf = spice(lambda x, y: operator.indexOf(x, y),
                name='indexOf',
                doc=operator.indexOf.__doc__)
is_ = spice(lambda x, y: operator.is_(x, y),
            name='is_',
            doc=operator.is_.__doc__)
is_not = spice(lambda x, y: operator.is_not(x, y),
               name='is_not',
               doc=operator.is_not.__doc__)

# reversed
le = spice(lambda x, y: operator.le(y, x), name='le')
__le__ = spice(lambda x, y: operator.__le__(y, x), name='__le__')

# reversed
lshift = spice(lambda x, y: operator.lshift(y, x), name='lshift')
__lshift__ = spice(lambda x, y: operator.__lshift__(y, x), name='__lshift__')

# reversed
lt = spice(lambda x, y: operator.lt(y, x), name='lt')
__lt__ = spice(lambda x, y: operator.__lt__(y, x), name='__lt__')

# reversed
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')