当前位置: 首页>>代码示例>>Python>>正文


Python operator.__getitem__方法代码示例

本文整理汇总了Python中operator.__getitem__方法的典型用法代码示例。如果您正苦于以下问题:Python operator.__getitem__方法的具体用法?Python operator.__getitem__怎么用?Python operator.__getitem__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operator的用法示例。


在下文中一共展示了operator.__getitem__方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testAccess

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __getitem__ [as 别名]
def testAccess(self):
        A = matrix([2, 3])
        self.failUnlessEqual(str(A), "unnamed_matrix{=((unnamed_matrix[0, 0], unnamed_matrix[0, 1], unnamed_matrix[0, 2]), (unnamed_matrix[1, 0], unnamed_matrix[1, 1], unnamed_matrix[1, 2]))}")
        self.failUnlessEqual(A[0, 0].is_set(), 0)
        self.failUnlessEqual(A[1, 0].is_set(), 0)
        self.failUnlessRaises(IndexError, operator.__getitem__, A, (2, 0))
        self.failUnlessEqual(A[0, 1].is_set(), 0)
        self.failUnlessEqual(A[1, 1].is_set(), 0)
        self.failUnlessEqual(A[0, 2].is_set(), 0)
        self.failUnlessEqual(A[1, 2].is_set(), 0)
        self.failUnlessRaises(IndexError, operator.__getitem__, A, (0, 3))
        A[0, 0].set(1)
        self.failUnlessEqual(A[0, 0].is_set(), 1)
        self.failUnlessEqual(A[0, 1].is_set(), 0)
        self.failUnlessEqual(A[1, 0].is_set(), 0)
        self.failUnlessAlmostEqual(A[0, 0].get(), 1.0)
        self.failUnlessAlmostEqual(float(A[0, 0]), 1.0) 
开发者ID:pyx-project,项目名称:pyx,代码行数:19,代码来源:test_solve.py

示例2: decompile

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __getitem__ [as 别名]
def decompile(cls, ea):
        '''(UNSTABLE) Returns the decompiled code of the basic block at the address `ea`.'''
        source = idaapi.decompile(ea)

        res = itertools.imap(functools.partial(operator.__getitem__, source.eamap), cls.iterate(ea))
        res = itertools.chain(*res)
        formatted = reduce(lambda t, c: t if t[-1].ea == c.ea else t+[c], res, [next(res)])

        res = []
        # FIXME: This has been pretty damn unstable in my tests.
        try:
            for fmt in formatted:
                res.append( fmt.print1(source.__deref__()) )
        except TypeError: pass
        res = itertools.imap(idaapi.tag_remove, res)
        return '\n'.join(map(utils.string.of, res)) 
开发者ID:arizvisa,项目名称:ida-minsc,代码行数:18,代码来源:function.py

示例3: testIReadMapping

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __getitem__ [as 别名]
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.assertTrue(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:basemapping.py

示例4: testIReadMapping

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __getitem__ [as 别名]
def testIReadMapping(self, inst, state, absent):
    for key in state:
        self.assertEqual(inst[key], state[key])
        self.assertEqual(inst.get(key, None), state[key])
        self.failUnless(key in inst)

    for key in absent:
        self.assertEqual(inst.get(key, None), None)
        self.assertEqual(inst.get(key), None)
        self.assertEqual(inst.get(key, self), self)
        self.assertRaises(KeyError, __getitem__, inst, key) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:basemapping.py


注:本文中的operator.__getitem__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。