Python operator.isSequenceType() Examples
The following are 30
code examples of operator.isSequenceType().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
operator
, or try the search function
.
Example #1
Source File: test_bool.py From ironpython2 with Apache License 2.0 | 7 votes |
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)
Example #2
Source File: test_bool.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: test_bool.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: Image.py From CNCGToolKit with MIT License | 5 votes |
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.
Example #5
Source File: awmstools.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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!
Example #6
Source File: test_operator.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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()))
Example #7
Source File: test_bool.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
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)
Example #8
Source File: dok.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _is_sequence(x): return (hasattr(x, '__len__') or hasattr(x, '__next__') or hasattr(x, 'next'))
Example #9
Source File: error.py From python-for-android with Apache License 2.0 | 5 votes |
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
Example #10
Source File: test_operator_jy.py From medicare-demo with Apache License 2.0 | 5 votes |
def test_isSequenceType(self): for obj, _, _, isSequenceType in self.tests: self.assert_istype(operator.isSequenceType, obj, isSequenceType)
Example #11
Source File: test_operator.py From medicare-demo with Apache License 2.0 | 5 votes |
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()))
Example #12
Source File: test_bool.py From medicare-demo with Apache License 2.0 | 5 votes |
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)
Example #13
Source File: server.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
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
Example #14
Source File: awmstools.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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!
Example #15
Source File: test_operator_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_isSequenceType(self): for obj, _, _, isSequenceType in self.tests: self.assert_istype(operator.isSequenceType, obj, isSequenceType)
Example #16
Source File: test_operator.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
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()))
Example #17
Source File: test_operator_jy.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_isSequenceType(self): for obj, _, _, isSequenceType in self.tests: self.assert_istype(operator.isSequenceType, obj, isSequenceType)
Example #18
Source File: test_operator.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
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()))
Example #19
Source File: Image.py From keras-lambda with MIT License | 5 votes |
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.
Example #20
Source File: awmstools.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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!
Example #21
Source File: test_operator.py From ironpython2 with Apache License 2.0 | 5 votes |
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()))
Example #22
Source File: test_operator.py From BinderFilter with MIT License | 5 votes |
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()))
Example #23
Source File: test_bool.py From BinderFilter with MIT License | 5 votes |
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)
Example #24
Source File: dok.py From Computable with MIT License | 5 votes |
def _is_sequence(x): return (hasattr(x, '__len__') or hasattr(x, '__next__') or hasattr(x, 'next'))
Example #25
Source File: test_operator.py From oss-ftp with MIT License | 5 votes |
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()))
Example #26
Source File: test_bool.py From oss-ftp with MIT License | 5 votes |
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)
Example #27
Source File: dok.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _is_sequence(x): return (hasattr(x, '__len__') or hasattr(x, '__next__') or hasattr(x, 'next'))
Example #28
Source File: Image.py From mxnet-lambda with Apache License 2.0 | 5 votes |
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.
Example #29
Source File: awmstools.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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!
Example #30
Source File: awmstools.py From DeepLearning_Wavelet-LSTM with MIT License | 5 votes |
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!