Iterator slicing

Contents
  • The stop parameter
  • The start parameter
  • The step parameter

We discussed in the iterators lesson how Python iterators relate to Haskell lists. If you’re familiar with the itertoolsitertools module, these next few lessons are to help you get started quickly with Haskell’s Data.ListData.List module. We will also discuss a few of Python’s built-in functions.Python built-in functions All of the functions that we discuss here return iterators.

In all of the Python code examples, we assume that everything from itertools is imported:

from itertools import *

We’ll start by introducing islice,itertools.islice because we’ll need to use islice to demonstrate some of the other itertools functions.

Sign up for access to the full page, plus the complete archive and all the latest content.