Pyiterable API Documentation

Python comes with some nice built-in methods for operating on iterables, but it can get messy really quickly if you want to transform an iterable multiple times. Write more expressive code by chaining built-in transformations with this module.

Scroll down for examples.



Inspired by:

Instead of:

values = ["1", "2", "5", "9"]

to_int = map(lambda x: int(x), values)
filtered = filter(lambda x: x > 4)
sum = reduce(lambda a, b: a + b, to_int)


values = ["1", "2", "5", "9"]

sum = reduce(
    lambda a, b: a + b,
        lambda x: x > 4,
        map(lambda x: int(x), values)

do this:

from pyiterable import Iterable
values = Iterable(["1", "2", "5", "9"])

sum = (values
       .map(lambda x: int(x))
       .filter(lambda x: x > 4)
       .reduce(lambda a, b: a + b)



  • Added first(), which gives you the first value in Iterable, with an optional default if no values exist
  • Added mapmany(), which functions like map, except it expects more than one output for each item of Iterable


  • First release!
  • Iterable class with equivalent built-in functions related to iterables

Indices and tables