python类rshift()的实例源码

nodes.py 文件源码 项目:hyper-engine 作者: maxim5 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __rshift__(self, other):  return _op2(self, other, operator.rshift)
nodes.py 文件源码 项目:hyper-engine 作者: maxim5 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __rrshift__(self, other): return _op2(self, other, operator.rshift, rev=True)
test_operator.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def test_rshift(self):
        self.assertRaises(TypeError, operator.rshift)
        self.assertRaises(TypeError, operator.rshift, None, 42)
        self.assertTrue(operator.rshift(5, 1) == 2)
        self.assertTrue(operator.rshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.rshift, 2, -1)
test_operator.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_rshift(self):
        self.assertRaises(TypeError, operator.rshift)
        self.assertRaises(TypeError, operator.rshift, None, 42)
        self.assertTrue(operator.rshift(5, 1) == 2)
        self.assertTrue(operator.rshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.rshift, 2, -1)
peephole_opt.py 文件源码 项目:bytecode 作者: vstinner 项目源码 文件源码 阅读 132 收藏 0 点赞 0 评论 0
def eval_BINARY_RSHIFT(self, instr):
        return self.binop(operator.rshift, instr)
libintmath.py 文件源码 项目:Python-iBeacon-Scan 作者: NikNitro 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def rshift(x, n):
    """For an integer x, calculate x >> n with the fastest (floor)
    rounding. Unlike the plain Python expression (x >> n), n is
    allowed to be negative, in which case a left shift is performed."""
    if n >= 0: return x >> n
    else:      return x << (-n)
PythonUtil.py 文件源码 项目:POTCO-PS 作者: ksmit799 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def binaryRepr(number, max_length = 32):
    # This will only work reliably for relatively small numbers.
    # Increase the value of max_length if you think you're going
    # to use long integers
    assert number < 2L << max_length
    shifts = map (operator.rshift, max_length * [number], \
                  range (max_length - 1, -1, -1))
    digits = map (operator.mod, shifts, max_length * [2])
    if not digits.count (1): return 0
    digits = digits [digits.index (1):]
    return ''.join([repr(digit) for digit in digits])
test_util.py 文件源码 项目:go2mapillary 作者: enricofer 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __rshift__(self, y):
    return NonStandardInteger(operator.rshift(self.val, y))
test_util.py 文件源码 项目:go2mapillary 作者: enricofer 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __rrshift__(self, y):
    return NonStandardInteger(operator.rshift(y, self.val))
vec2d.py 文件源码 项目:Simulating-a-Self-Driving-Car 作者: Aniruddha-Tapas 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def __rshift__(self, other):
        return self._o2(other, operator.rshift)
vec2d.py 文件源码 项目:Simulating-a-Self-Driving-Car 作者: Aniruddha-Tapas 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __rrshift__(self, other):
        return self._r_o2(other, operator.rshift)
libintmath.py 文件源码 项目:OpenRAM 作者: mguthaus 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def rshift(x, n):
    """For an integer x, calculate x >> n with the fastest (floor)
    rounding. Unlike the plain Python expression (x >> n), n is
    allowed to be negative, in which case a left shift is performed."""
    if n >= 0: return x >> n
    else:      return x << (-n)
stdenv.py 文件源码 项目:gazelle 作者: surrsurus 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def make_env():
  ''' An environment with basic procedures. '''

  import math
  import cmath
  import itertools
  import operator as op

  env = Environment()

  env.update(vars(math))
  env.update(vars(cmath))
  env.update(vars(itertools))

  env.update({
    '>':          op.gt,     '<':       op.lt,    
    '>=':         op.ge,     '<=':      op.le,
    '=':          op.eq,
    '>>':         op.rshift, '<<':      op.lshift,
    '+':          lambda *x: reduce(op.add, x, 0),
    '-':          lambda *x: x[0] - sum(x[1:]),
    '*':          lambda *x: reduce(op.mul, x, 1),
    '/':          lambda *x: reduce(op.truediv, (x[1:]), x[0]),
    '//':         lambda *x: reduce(op.floordiv, (x[1:]), x[0]),
    '%':          op.mod,
    'abs':        abs,
    'append':     op.add,
    'apply':      lambda proc,l: proc(*l),
    'begin':      lambda *x: x[-1],
    'bool?':      lambda x: isinstance(x, bool),
    'call/cc':    callcc,
    'car':        lambda x: x[0],
    'cdr':        lambda x: x[1:],
    'cons':       lambda x,y: [x] + y,
    'filter':     lambda f,l: list(filter(f, l)),
    'length':     len, 
    'list':       lambda *x: list(x),
    'list?':      lambda x: isinstance(x,list), 
    # Map can be defined in the stdlib, though it will max out python's recursion depth
    'map':        lambda f,l: list(map(f, l)),
    'max':        max,
    'min':        min,
    'not':        op.not_,
    'number?':    lambda x: not isinstance(x, bool) and isinstance(x, int) or isinstance(x, float) or isinstance(x, complex),   
    'or':         op.or_,
    'proc?':      callable,
    'range':      lambda *x: list(range(x[0], x[1])) if len(x) > 1 else list(range(x[0])),
    'round':      round,
    'str?':       lambda x: isinstance(x, str),
    'sum':        lambda x: sum(x),
    })
  return env

# Create a global env for `gazeval()` to access


问题


面经


文章

微信
公众号

扫码关注公众号