本文整理汇总了Python中__builtin__.reversed方法的典型用法代码示例。如果您正苦于以下问题:Python __builtin__.reversed方法的具体用法?Python __builtin__.reversed怎么用?Python __builtin__.reversed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类__builtin__
的用法示例。
在下文中一共展示了__builtin__.reversed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reversed
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def reversed(data):
if not isinstance(data, list):
data = list(data)
return data[::-1]
示例2: __reversed__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def __reversed__(self):
return _coconut.reversed(self._xrange)
示例3: _coconut_back_compose
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def _coconut_back_compose(*funcs): return _coconut_forward_compose(*_coconut.reversed(funcs))
示例4: _coconut_back_star_compose
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def _coconut_back_star_compose(*funcs): return _coconut_forward_star_compose(*_coconut.reversed(funcs))
示例5: _coconut_back_dubstar_compose
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def _coconut_back_dubstar_compose(*funcs): return _coconut_forward_dubstar_compose(*_coconut.reversed(funcs))
示例6: __new__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def __new__(cls, iterable):
if _coconut.isinstance(iterable, _coconut.range):
return iterable[::-1]
if not _coconut.hasattr(iterable, "__reversed__") or _coconut.isinstance(iterable, (_coconut.list, _coconut.tuple)):
return _coconut.object.__new__(cls)
return _coconut.reversed(iterable)
示例7: __repr__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def __repr__(self):
return "reversed(%r)" % (self.iter,)
示例8: count
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def count(self, elem):
"""Count the number of times elem appears in the reversed iterator."""
return self.iter.count(elem)
示例9: index
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def index(self, elem):
"""Find the index of elem in the reversed iterator."""
return _coconut.len(self.iter) - self.iter.index(elem) - 1
示例10: __iter__
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def __iter__(self):
return _coconut.iter(_coconut.reversed(self.iter))
示例11: reversed
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def reversed(x):
try:
return __builtin__.reversed(x)
except TypeError:
return reversed(list(x))
示例12: string_to_natural
# 需要导入模块: import __builtin__ [as 别名]
# 或者: from __builtin__ import reversed [as 别名]
def string_to_natural(s, alphabet=None):
if alphabet is None:
assert not s.startswith('\x00')
return int(s.encode('hex'), 16) if s else 0
else:
assert len(set(alphabet)) == len(alphabet)
assert not s.startswith(alphabet[0])
return sum(alphabet.index(char) * len(alphabet)**i for i, char in enumerate(reversed(s)))