python类lshift()的实例源码

YoutubeCom.py 文件源码 项目:download-manager 作者: thispc 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self, code, objects=None):
        self._OPERATORS = [
            ('|', operator.or_),
            ('^', operator.xor),
            ('&', operator.and_),
            ('>>', operator.rshift),
            ('<<', operator.lshift),
            ('-', operator.sub),
            ('+', operator.add),
            ('%', operator.mod),
            ('/', operator.truediv),
            ('*', operator.mul),
        ]
        self._ASSIGN_OPERATORS = [(op + '=', opfunc)
                                  for op, opfunc in self._OPERATORS]
        self._ASSIGN_OPERATORS.append(('=', lambda cur, right: right))
        self._VARNAME_PATTERN = r'[a-zA-Z_$][a-zA-Z_$0-9]*'

        if objects is None:
            objects = {}
        self.code = code
        self._functions = {}
        self._objects = objects
utils.py 文件源码 项目:pudzu 作者: Udzu 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def number_of_args(fn):
    """Return the number of positional arguments for a function, or None if the number is variable.
    Looks inside any decorated functions."""
    try:
        if hasattr(fn, '__wrapped__'):
            return number_of_args(fn.__wrapped__)
        if any(p.kind == p.VAR_POSITIONAL for p in signature(fn).parameters.values()):
            return None
        else:
            return sum(p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) for p in signature(fn).parameters.values())
    except ValueError:
        # signatures don't work for built-in operators, so check for a few explicitly
        UNARY_OPS = [len, op.not_, op.truth, op.abs, op.index, op.inv, op.invert, op.neg, op.pos]
        BINARY_OPS = [op.lt, op.le, op.gt, op.ge, op.eq, op.ne, op.is_, op.is_not, op.add, op.and_, op.floordiv, op.lshift, op.mod, op.mul, op.or_, op.pow, op.rshift, op.sub, op.truediv, op.xor, op.concat, op.contains, op.countOf, op.delitem, op.getitem, op.indexOf]
        TERNARY_OPS = [op.setitem]
        if fn in UNARY_OPS:
            return 1
        elif fn in BINARY_OPS:
            return 2
        elif fn in TERNARY_OPS:
            return 3
        else:
            raise NotImplementedError("Bult-in operator {} not supported".format(fn))
YoutubeCom.py 文件源码 项目:pyload-plugins 作者: pyload 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def __init__(self, code, objects=None):
        self._OPERATORS = [
            ('|', operator.or_),
            ('^', operator.xor),
            ('&', operator.and_),
            ('>>', operator.rshift),
            ('<<', operator.lshift),
            ('-', operator.sub),
            ('+', operator.add),
            ('%', operator.mod),
            ('/', operator.truediv),
            ('*', operator.mul),
        ]
        self._ASSIGN_OPERATORS = [(op + '=', opfunc)
                                  for op, opfunc in self._OPERATORS]
        self._ASSIGN_OPERATORS.append(('=', lambda cur, right: right))
        self._VARNAME_PATTERN = r'[a-zA-Z_$][a-zA-Z_$0-9]*'

        if objects is None:
            objects = {}
        self.code = code
        self._functions = {}
        self._objects = objects
SPI.py 文件源码 项目:darkwater_python_escape 作者: darkwaterio 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def set_bit_order(self, order):
        """Set order of bits to be read/written over serial lines.  Should be
        either MSBFIRST for most-significant first, or LSBFIRST for
        least-signifcant first.
        """
        # Set self._mask to the bitmask which points at the appropriate bit to
        # read or write, and appropriate left/right shift operator function for
        # reading/writing.
        if order == MSBFIRST:
            self._mask = 0x80
            self._write_shift = operator.lshift
            self._read_shift = operator.rshift
        elif order == LSBFIRST:
            self._mask = 0x01
            self._write_shift = operator.rshift
            self._read_shift = operator.lshift
        else:
            raise ValueError('Order must be MSBFIRST or LSBFIRST.')
myhdlpeek.py 文件源码 项目:myhdlpeek 作者: xesscorp 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __lshift__(self, trc):
        return self.apply_op2(trc, operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_lshift_scalar(self):
        self.check_array_scalar_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_rlshift_scalar(self):
        self.check_array_scalar_op(operator.lshift, swap=True)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_lshift_scalarzero(self):
        self.check_array_scalarzero_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_rlshift_scalarzero(self):
        self.check_array_scalarzero_op(operator.lshift, swap=True)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def test_lshift_array(self):
        self.check_array_array_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:cupy 作者: cupy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_doubly_broadcasted_lshift(self):
        self.check_array_doubly_broadcasted_op(operator.lshift)
libintmath.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def lshift(x, n):
    """For an integer x, calculate x << n. Unlike the plain Python
    expression (x << n), n is allowed to be negative, in which case a
    right shift with default (floor) rounding is performed."""
    if n >= 0: return x << n
    else:      return x >> (-n)
test_operator.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_lshift(self):
        self.assertRaises(TypeError, operator.lshift)
        self.assertRaises(TypeError, operator.lshift, None, 42)
        self.assertTrue(operator.lshift(5, 1) == 10)
        self.assertTrue(operator.lshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.lshift, 2, -1)
libintmath.py 文件源码 项目:twic_close_reading 作者: jarmoza 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def lshift(x, n):
    """For an integer x, calculate x << n. Unlike the plain Python
    expression (x << n), n is allowed to be negative, in which case a
    right shift with default (floor) rounding is performed."""
    if n >= 0: return x << n
    else:      return x >> (-n)
test_util.py 文件源码 项目:Vector-Tiles-Reader-QGIS-Plugin 作者: geometalab 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __lshift__(self, y):
    return NonStandardInteger(operator.lshift(self.val, y))
test_util.py 文件源码 项目:Vector-Tiles-Reader-QGIS-Plugin 作者: geometalab 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __rlshift__(self, y):
    return NonStandardInteger(operator.lshift(y, self.val))
libintmath.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def lshift(x, n):
    """For an integer x, calculate x << n. Unlike the plain Python
    expression (x << n), n is allowed to be negative, in which case a
    right shift with default (floor) rounding is performed."""
    if n >= 0: return x << n
    else:      return x >> (-n)
test_operator.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_lshift(self):
        self.assertRaises(TypeError, operator.lshift)
        self.assertRaises(TypeError, operator.lshift, None, 42)
        self.assertTrue(operator.lshift(5, 1) == 10)
        self.assertTrue(operator.lshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.lshift, 2, -1)
test_operator.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_lshift(self):
        self.assertRaises(TypeError, operator.lshift)
        self.assertRaises(TypeError, operator.lshift, None, 42)
        self.assertTrue(operator.lshift(5, 1) == 10)
        self.assertTrue(operator.lshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.lshift, 2, -1)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_lshift_scalar(self):
        self.check_array_scalar_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_rlshift_scalar(self):
        self.check_array_scalar_op(operator.lshift, swap=True)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_lshift_scalarzero(self):
        self.check_array_scalarzero_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_rlshift_scalarzero(self):
        self.check_array_scalarzero_op(operator.lshift, swap=True)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_lshift_array(self):
        self.check_array_array_op(operator.lshift)
test_ndarray_elementwise_op.py 文件源码 项目:chainer-deconv 作者: germanRos 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_doubly_broadcasted_lshift(self):
        self.check_array_doubly_broadcasted_op(operator.lshift)
test_util.py 文件源码 项目:coremltools 作者: apple 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __lshift__(self, y):
    return NonStandardInteger(operator.lshift(self.val, y))
test_util.py 文件源码 项目:coremltools 作者: apple 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def __rlshift__(self, y):
    return NonStandardInteger(operator.lshift(y, self.val))
test_operator.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_lshift(self):
        self.assertRaises(TypeError, operator.lshift)
        self.assertRaises(TypeError, operator.lshift, None, 42)
        self.assertTrue(operator.lshift(5, 1) == 10)
        self.assertTrue(operator.lshift(5, 0) == 5)
        self.assertRaises(ValueError, operator.lshift, 2, -1)
nauticalcombat.py 文件源码 项目:nautical-combat 作者: horstjens 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __lshift__(self, other):
        return self._o2(other, operator.lshift)
nauticalcombat.py 文件源码 项目:nautical-combat 作者: horstjens 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __rlshift__(self, other):
        return self._r_o2(other, operator.lshift)


问题


面经


文章

微信
公众号

扫码关注公众号