Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 504 Bytes

File metadata and controls

22 lines (15 loc) · 504 Bytes

itertools.chain

Combines multiple iterables into a single sequence without building a new list in memory. See itertools — Python docs.

Usage

from itertools import chain
chain(iterable1, iterable2, ...)

Covered

  • Chaining lists of different types
  • Flattening a list of lists with chain(*list_of_lists)
  • Memory efficiency — chain returns a lazy iterator

Run

python itertools_chain.py