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


Python operator.__iadd__方法代码示例

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


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

示例1: test_iadd

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __iadd__ [as 别名]
def test_iadd(self):
        super(CommonTest, self).test_iadd()
        u = self.type2test([0, 1])
        u2 = u
        u += [2, 3]
        self.assert_(u is u2)

        u = self.type2test("spam")
        u += "eggs"
        self.assertEqual(u, self.type2test("spameggs"))

        if not test_support.is_jython:
            self.assertRaises(TypeError, u.__iadd__, None)
        else:
            import operator
            self.assertRaises(TypeError, operator.__iadd__, u, None) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:18,代码来源:list_tests.py

示例2: test_iadd

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __iadd__ [as 别名]
def test_iadd(self):
        super(CommonTest, self).test_iadd()
        u = self.type2test([0, 1])
        u2 = u
        u += [2, 3]
        self.assertIs(u, u2)

        u = self.type2test("spam")
        u += "eggs"
        self.assertEqual(u, self.type2test("spameggs"))

        if not test_support.is_jython:
            self.assertRaises(TypeError, u.__iadd__, None)
        else:
            import operator
            self.assertRaises(TypeError, operator.__iadd__, u, None) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:18,代码来源:list_tests.py

示例3: report

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __iadd__ [as 别名]
def report(f, d):
    all_foos = reduce(operator.__iadd__, f.values(), [])
    all_direct_foos = reduce(operator.__iadd__, d.values(), [])
    return make_info("FOO", num_all_foos=len(all_foos), num_direct_foos=len(all_direct_foos)) 
开发者ID:RedHatInsights,项目名称:insights-core,代码行数:6,代码来源:test_find.py

示例4: test_inplace

# 需要导入模块: import operator [as 别名]
# 或者: from operator import __iadd__ [as 别名]
def test_inplace(self):
        class C(object):
            def __iadd__     (self, other): return "iadd"
            def __iand__     (self, other): return "iand"
            def __idiv__     (self, other): return "idiv"
            def __ifloordiv__(self, other): return "ifloordiv"
            def __ilshift__  (self, other): return "ilshift"
            def __imod__     (self, other): return "imod"
            def __imul__     (self, other): return "imul"
            def __ior__      (self, other): return "ior"
            def __ipow__     (self, other): return "ipow"
            def __irshift__  (self, other): return "irshift"
            def __isub__     (self, other): return "isub"
            def __itruediv__ (self, other): return "itruediv"
            def __ixor__     (self, other): return "ixor"
            def __getitem__(self, other): return 5  # so that C is a sequence
        c = C()
        self.assertEqual(operator.iadd     (c, 5), "iadd")
        self.assertEqual(operator.iand     (c, 5), "iand")
        self.assertEqual(operator.idiv     (c, 5), "idiv")
        self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
        self.assertEqual(operator.ilshift  (c, 5), "ilshift")
        self.assertEqual(operator.imod     (c, 5), "imod")
        self.assertEqual(operator.imul     (c, 5), "imul")
        self.assertEqual(operator.ior      (c, 5), "ior")
        self.assertEqual(operator.ipow     (c, 5), "ipow")
        self.assertEqual(operator.irshift  (c, 5), "irshift")
        self.assertEqual(operator.isub     (c, 5), "isub")
        self.assertEqual(operator.itruediv (c, 5), "itruediv")
        self.assertEqual(operator.ixor     (c, 5), "ixor")
        self.assertEqual(operator.iconcat  (c, c), "iadd")
        self.assertEqual(operator.irepeat  (c, 5), "imul")
        self.assertEqual(operator.__iadd__     (c, 5), "iadd")
        self.assertEqual(operator.__iand__     (c, 5), "iand")
        self.assertEqual(operator.__idiv__     (c, 5), "idiv")
        self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv")
        self.assertEqual(operator.__ilshift__  (c, 5), "ilshift")
        self.assertEqual(operator.__imod__     (c, 5), "imod")
        self.assertEqual(operator.__imul__     (c, 5), "imul")
        self.assertEqual(operator.__ior__      (c, 5), "ior")
        self.assertEqual(operator.__ipow__     (c, 5), "ipow")
        self.assertEqual(operator.__irshift__  (c, 5), "irshift")
        self.assertEqual(operator.__isub__     (c, 5), "isub")
        self.assertEqual(operator.__itruediv__ (c, 5), "itruediv")
        self.assertEqual(operator.__ixor__     (c, 5), "ixor")
        self.assertEqual(operator.__iconcat__  (c, c), "iadd")
        self.assertEqual(operator.__irepeat__  (c, 5), "imul") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:49,代码来源:test_operator.py


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