Python __builtin__.reversed() Examples

The following are 23 code examples of __builtin__.reversed(). 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 __builtin__ , or try the search function .
Example #1
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def index(self, elem):
        """Find the index of elem in the reversed iterator."""
        return _coconut.len(self.iter) - self.iter.index(elem) - 1 
Example #2
Source File: compatibility.py    From EasY_HaCk with Apache License 2.0 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            reversed_data = []
            for index in xrange(len(data)-1, -1, -1):
                reversed_data.append(data[index])
            return reversed_data

# --- sorted() from Python 2.4 --- 
Example #3
Source File: compatibility.py    From EasY_HaCk with Apache License 2.0 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            return data[::-1] 
Example #4
Source File: math.py    From p2pool-n with GNU General Public License v3.0 5 votes vote down vote up
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))) 
Example #5
Source File: math.py    From p2pool-n with GNU General Public License v3.0 5 votes vote down vote up
def reversed(x):
    try:
        return __builtin__.reversed(x)
    except TypeError:
        return reversed(list(x)) 
Example #6
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def count(self, elem):
        """Count the number of times elem appears in the reversed iterator."""
        return self.iter.count(elem) 
Example #7
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        return "reversed(%r)" % (self.iter,) 
Example #8
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __iter__(self):
        return _coconut.iter(_coconut.reversed(self.iter)) 
Example #9
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
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) 
Example #10
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def _coconut_back_dubstar_compose(*funcs): return _coconut_forward_dubstar_compose(*_coconut.reversed(funcs)) 
Example #11
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def _coconut_back_compose(*funcs): return _coconut_forward_compose(*_coconut.reversed(funcs)) 
Example #12
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __reversed__(self):
            return _coconut.reversed(self._xrange) 
Example #13
Source File: compatibility.py    From Yuki-Chan-The-Auto-Pentest with MIT License 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            return data[::-1] 
Example #14
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def count(self, elem):
        """Count the number of times elem appears in the reversed iterator."""
        return self.iter.count(elem) 
Example #15
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        return "reversed(%r)" % (self.iter,) 
Example #16
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
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) 
Example #17
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def _coconut_back_dubstar_compose(*funcs): return _coconut_forward_dubstar_compose(*_coconut.reversed(funcs)) 
Example #18
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def _coconut_back_star_compose(*funcs): return _coconut_forward_star_compose(*_coconut.reversed(funcs)) 
Example #19
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def _coconut_back_compose(*funcs): return _coconut_forward_compose(*_coconut.reversed(funcs)) 
Example #20
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __reversed__(self):
            return _coconut.reversed(self._xrange) 
Example #21
Source File: compatibility.py    From ITWSV with MIT License 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            reversed_data = []
            for index in xrange(len(data)-1, -1, -1):
                reversed_data.append(data[index])
            return reversed_data

# --- sorted() from Python 2.4 --- 
Example #22
Source File: compatibility.py    From ITWSV with MIT License 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            return data[::-1] 
Example #23
Source File: compatibility.py    From Yuki-Chan-The-Auto-Pentest with MIT License 5 votes vote down vote up
def reversed(data):
            if not isinstance(data, list):
                data = list(data)
            reversed_data = []
            for index in xrange(len(data)-1, -1, -1):
                reversed_data.append(data[index])
            return reversed_data

# --- sorted() from Python 2.4 ---