本文整理汇总了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)
示例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)
示例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'))
示例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()))
示例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.
示例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!
示例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
示例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)
示例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()))
示例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
示例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.