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


Python operator.truth方法代码示例

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


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

示例1: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [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: boolean

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def boolean(value, _truefalse=(False, True)):
        """Convert any Python value to XML-RPC 'boolean'."""
        return _truefalse[operator.truth(value)]

##
# Wrapper for XML-RPC DateTime values.  This converts a time value to
# the format used by XML-RPC.
# <p>
# The value can be given as a string in the format
# "yyyymmddThh:mm:ss", as a 9-item time tuple (as returned by
# time.localtime()), or an integer value (as returned by time.time()).
# The wrapper uses time.localtime() to convert an integer to a time
# tuple.
#
# @param value The time, given as an ISO 8601 string, a time
#              tuple, or a integer time value. 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:18,代码来源:_pydev_xmlrpclib.py

示例3: test_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [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

示例4: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def __init__(self, value = 0):
            self.value = operator.truth(value) 
开发者ID:glmcdona,项目名称:meddle,代码行数:4,代码来源:xmlrpclib.py

示例5: boolean

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def boolean(value, _truefalse=(False, True)):
        """Convert any Python value to XML-RPC 'boolean'."""
        return _truefalse[operator.truth(value)] 
开发者ID:glmcdona,项目名称:meddle,代码行数:5,代码来源:xmlrpclib.py

示例6: test_bool_values

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def test_bool_values(self):
        from operator import truth
        for t, v in zip(bool_types, bool_values):
            self.assertEqual(t(v).value, truth(v)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_numbers.py

示例7: test_truth

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def test_truth(self):
        class C(object):
            def __nonzero__(self):
                raise SyntaxError
        self.assertRaises(TypeError, operator.truth)
        self.assertRaises(SyntaxError, operator.truth, C())
        self.assertTrue(operator.truth(5))
        self.assertTrue(operator.truth([0]))
        self.assertFalse(operator.truth(0))
        self.assertFalse(operator.truth([])) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_operator.py

示例8: parse_stdout_filelist

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def parse_stdout_filelist(hg_out_filelist):
    files = hg_out_filelist.split()
    files = [f.strip(string.whitespace + "'") for f in files]
    files = list(filter(operator.truth, files))  # get rid of empty entries
    return files 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:7,代码来源:check_whitespace.py

示例9: __init__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def __init__(self, value=0):
            self.value = operator.truth(value) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:4,代码来源:_pydev_xmlrpclib.py

示例10: getBroadcastAllowed

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def getBroadcastAllowed(self):
        """
        Checks if broadcast is currently allowed on this port.

        @return: Whether this port may broadcast.
        @rtype: L{bool}
        """
        return operator.truth(
            self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:udp.py

示例11: setLoopbackMode

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def setLoopbackMode(self, mode):
        mode = struct.pack("b", operator.truth(mode))
        self.socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP,
                               mode) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:udp.py

示例12: getTcpNoDelay

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def getTcpNoDelay(self):
        return operator.truth(self.socket.getsockopt(socket.IPPROTO_TCP,
                                                     socket.TCP_NODELAY)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:tcp.py

示例13: getTcpKeepAlive

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def getTcpKeepAlive(self):
        return operator.truth(self.socket.getsockopt(socket.SOL_SOCKET,
                                                     socket.SO_KEEPALIVE)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:tcp.py

示例14: getTcpNoDelay

# 需要导入模块: import operator [as 别名]
# 或者: from operator import truth [as 别名]
def getTcpNoDelay(self):
        return operator.truth(self.socket.getsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:4,代码来源:tcp.py


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