本文整理匯總了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)))