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


Python operator.isSequenceType方法代码示例

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


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

示例1: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:25,代码来源:test_bool.py

示例2: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.isCallable(0), False)
        self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:24,代码来源:test_bool.py

示例3: _is_sequence

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def _is_sequence(x):
        return (hasattr(x, '__len__') or hasattr(x, '__next__')
                or hasattr(x, 'next')) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:dok.py

示例4: test_isSequenceType

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def test_isSequenceType(self):
        self.assertRaises(TypeError, operator.isSequenceType)
        self.assertTrue(operator.isSequenceType(dir()))
        self.assertTrue(operator.isSequenceType(()))
        self.assertTrue(operator.isSequenceType(xrange(10)))
        self.assertTrue(operator.isSequenceType('yeahbuddy'))
        self.assertFalse(operator.isSequenceType(3))
        class Dict(dict): pass
        self.assertFalse(operator.isSequenceType(Dict())) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test_operator.py

示例5: point

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def point(self, lut, mode=None):
        "Map image through lookup table"

        self.load()

        if not isSequenceType(lut):
            # if it isn't a list, it should be a function
            if self.mode in ("I", "I;16", "F"):
                # check if the function can be used with point_transform
                scale, offset = _getscaleoffset(lut)
                return self._new(self.im.point_transform(scale, offset))
            # for other modes, convert the function to a table
            lut = map(lut, range(256)) * self.im.bands

        if self.mode == "F":
            # FIXME: _imaging returns a confusing error message for this case
            raise ValueError("point operation not supported for this mode")

        return self._new(self.im.point(lut, mode))

    ##
    # Adds or replaces the alpha layer in this image.  If the image
    # does not have an alpha layer, it's converted to "LA" or "RGBA".
    # The new layer must be either "L" or "1".
    #
    # @param im The new alpha layer.  This can either be an "L" or "1"
    #    image having the same size as this image, or an integer or
    #    other color value. 
开发者ID:awslabs,项目名称:mxnet-lambda,代码行数:30,代码来源:Image.py

示例6: isSeq

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def isSeq(obj):
    r"""Returns true if obj is a sequence (which does purposefully **not**
    include strings, because these are pseudo-sequences that mess
    up recursion.)"""
    return operator.isSequenceType(obj) and not isinstance(obj, (str, unicode))



# os.path's splitext is EVIL: it thinks that dotfiles are extensions! 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:11,代码来源:awmstools.py

示例7: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def __init__(self, allowedMethods, *args):
        Exception.__init__(self, allowedMethods, *args)
        self.allowedMethods = allowedMethods

        if not operator.isSequenceType(allowedMethods):
            why = "but my first argument is not a sequence."
            s = ("First argument must be a sequence of"
                 " supported methods, %s" % (why,))
            raise TypeError, s 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:error.py

示例8: test_isSequenceType

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def test_isSequenceType(self):
        for obj, _, _, isSequenceType in self.tests:
            self.assert_istype(operator.isSequenceType, obj, isSequenceType) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:5,代码来源:test_operator_jy.py

示例9: test_isSequenceType

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def test_isSequenceType(self):
        self.failUnlessRaises(TypeError, operator.isSequenceType)
        self.failUnless(operator.isSequenceType(dir()))
        self.failUnless(operator.isSequenceType(()))
        self.failUnless(operator.isSequenceType(xrange(10)))
        self.failUnless(operator.isSequenceType('yeahbuddy'))
        self.failIf(operator.isSequenceType(3))
        class Dict(dict): pass
        self.failIf(operator.isSequenceType(Dict())) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_operator.py

示例10: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def __init__(self, allowedMethods, *args):
        Exception.__init__(self, allowedMethods, *args)
        self.allowedMethods = allowedMethods
        
        if not operator.isSequenceType(allowedMethods):
            why = "but my first argument is not a sequence."
            s = ("First argument must be a sequence of"
                 " supported methods, %s" % (why,))
            raise TypeError, s 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:11,代码来源:server.py

示例11: point

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isSequenceType [as 别名]
def point(self, lut, mode=None):
        "Map image through lookup table"

        self.load()

        if isinstance(lut, ImagePointHandler):
            return lut.point(self)

        if not isSequenceType(lut):
            # if it isn't a list, it should be a function
            if self.mode in ("I", "I;16", "F"):
                # check if the function can be used with point_transform
                scale, offset = _getscaleoffset(lut)
                return self._new(self.im.point_transform(scale, offset))
            # for other modes, convert the function to a table
            lut = map(lut, range(256)) * self.im.bands

        if self.mode == "F":
            # FIXME: _imaging returns a confusing error message for this case
            raise ValueError("point operation not supported for this mode")

        return self._new(self.im.point(lut, mode))

    ##
    # Adds or replaces the alpha layer in this image.  If the image
    # does not have an alpha layer, it's converted to "LA" or "RGBA".
    # The new layer must be either "L" or "1".
    #
    # @param im The new alpha layer.  This can either be an "L" or "1"
    #    image having the same size as this image, or an integer or
    #    other color value. 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:33,代码来源:Image.py


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