OpenQuizz
Une application de gestion des contenus pédagogiques
islice_extended Class Reference

Public Member Functions

def __init__ (self, iterable, *args)
 
def __iter__ (self)
 
def __next__ (self)
 
def __getitem__ (self, key)
 

Detailed Description

An extension of :func:`itertools.islice` that supports negative values
for *stop*, *start*, and *step*.

    >>> iterable = iter('abcdefgh')
    >>> list(islice_extended(iterable, -4, -1))
    ['e', 'f', 'g']

Slices with negative values require some caching of *iterable*, but this
function takes care to minimize the amount of memory required.

For example, you can use a negative step with an infinite iterator:

    >>> from itertools import count
    >>> list(islice_extended(count(), 110, 99, -2))
    [110, 108, 106, 104, 102, 100]

You can also use slice notation directly:

    >>> iterable = map(str, count())
    >>> it = islice_extended(iterable)[10:20:2]
    >>> list(it)
    ['10', '12', '14', '16', '18']

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  iterable,
args 
)

Member Function Documentation

◆ __getitem__()

def __getitem__ (   self,
  key 
)

◆ __iter__()

def __iter__ (   self)

◆ __next__()

def __next__ (   self)

The documentation for this class was generated from the following file: