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


Python utils.isnewbytes方法代码示例

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


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

示例1: __contains__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __contains__(self, key):
        errmsg = "'in <string>' requires string as left operand, not {0}"
        # Don't use isinstance() here because we only want to catch
        # newstr, not Python 2 unicode:
        if type(key) == newstr:
            newkey = key
        elif isinstance(key, unicode) or isinstance(key, bytes) and not isnewbytes(key):
            newkey = newstr(key)
        else:
            raise TypeError(errmsg.format(type(key)))
        return issubset(list(newkey), list(self)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:13,代码来源:newstr.py

示例2: join

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def join(self, iterable):
        errmsg = 'sequence item {0}: expected unicode string, found bytes'
        for i, item in enumerate(iterable):
            # Here we use type() rather than isinstance() because
            # __instancecheck__ is being overridden. E.g.
            # isinstance(b'abc', newbytes) is True on Py2.
            if isnewbytes(item):
                raise TypeError(errmsg.format(i))
        # Support use as a staticmethod: str.join('-', ['a', 'b'])
        if type(self) == newstr:
            return newstr(super(newstr, self).join(iterable))
        else:
            return newstr(super(newstr, newstr(self)).join(iterable)) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:15,代码来源:newstr.py

示例3: startswith

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def startswith(self, prefix, *args):
        if isinstance(prefix, Iterable):
            for thing in prefix:
                if isnewbytes(thing):
                    raise TypeError(self.no_convert_msg.format(type(thing)))
        return super(newstr, self).startswith(prefix, *args) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:8,代码来源:newstr.py

示例4: endswith

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def endswith(self, prefix, *args):
        # Note we need the decorator above as well as the isnewbytes()
        # check because prefix can be either a bytes object or e.g. a
        # tuple of possible prefixes. (If it's a bytes object, each item
        # in it is an int.)
        if isinstance(prefix, Iterable):
            for thing in prefix:
                if isnewbytes(thing):
                    raise TypeError(self.no_convert_msg.format(type(thing)))
        return super(newstr, self).endswith(prefix, *args) 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:12,代码来源:newstr.py

示例5: __eq__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __eq__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__eq__(other)
        else:
            return False 
开发者ID:Soft8Soft,项目名称:verge3d-blender-addon,代码行数:8,代码来源:newstr.py

示例6: __lt__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __lt__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__lt__(other)
        raise TypeError(self.unorderable_err.format(type(other))) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:newstr.py

示例7: __le__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __le__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__le__(other)
        raise TypeError(self.unorderable_err.format(type(other))) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:newstr.py

示例8: __gt__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __gt__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__gt__(other)
        raise TypeError(self.unorderable_err.format(type(other))) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:newstr.py

示例9: __ge__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __ge__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__ge__(other)
        raise TypeError(self.unorderable_err.format(type(other))) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:7,代码来源:newstr.py

示例10: __ne__

# 需要导入模块: from future import utils [as 别名]
# 或者: from future.utils import isnewbytes [as 别名]
def __ne__(self, other):
        if (isinstance(other, unicode) or
            isinstance(other, bytes) and not isnewbytes(other)):
            return super(newstr, self).__ne__(other)
        else:
            return True 
开发者ID:remg427,项目名称:misp42splunk,代码行数:8,代码来源:newstr.py


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