def __init__(self, iterable, *args):
        """Inititalize the iterable with start, stop, and step values."""
        if not args:

            raise TypeError('islice expected at least 2 arguments, got 1')

        if len(args) == 1:

            start, stop, step = 0, args[0], 1

        if len(args) == 2:

            start, stop = args
            step = 1

        if len(args) == 3:

            start, stop, step = args

        if len(args) > 3:

            raise TypeError(
                'islice expected at most 4 arguments, got {}'.format(len(args))
            )

        start = start if start is not None else 0
        step = step if step is not None else 1

        if start is not None and not isinstance(start, int):

            raise ValueError('The start value must be an integer.')

        if stop is not None and not isinstance(stop, int):

            raise ValueError('The stop value must be an integer.')

        if step is not None and not isinstance(step, int):

            raise ValueError('The step value must be an integer.')

        if start < 0:

            raise ValueError('The start value cannot be negative.')

        if stop is not None and stop < 0:

            raise ValueError('The stop value cannot be negative.')

        if step < 1:

            raise ValueError('The step value cannot be negative or zero.')

        self._start, self._step, self._stop = start, step, stop
        self._iterable = iterable
        self._initialized = False
        self._offset = 0
        self._depleted = False
def __init__ ( self , iterable , * args ) : if not args : raise TypeError ( 'islice expected at least 2 arguments, got 1' ) if len ( args ) == 1 : start , stop , step = 0 , args [ 0 ] , 1 if len ( args ) == 2 : start , stop = args step = 1 if len ( args ) == 3 : start , stop , step = args if len ( args ) > 3 : raise TypeError ( 'islice expected at most 4 arguments, got {}' . format ( len ( args ) ) ) start = start if start is not None else 0 step = step if step is not None else 1 if start is not None and not isinstance ( start , int ) : raise ValueError ( 'The start value must be an integer.' ) if stop is not None and not isinstance ( stop , int ) : raise ValueError ( 'The stop value must be an integer.' ) if step is not None and not isinstance ( step , int ) : raise ValueError ( 'The step value must be an integer.' ) if start < 0 : raise ValueError ( 'The start value cannot be negative.' ) if stop is not None and stop < 0 : raise ValueError ( 'The stop value cannot be negative.' ) if step < 1 : raise ValueError ( 'The step value cannot be negative or zero.' ) self . _start , self . _step , self . _stop = start , step , stop self . _iterable = iterable self . _initialized = False self . _offset = 0 self . _depleted = False
Inititalize the iterable with start, stop, and step values.