Skip to main content

Object orientated iterator wrapper.

Project description

iteroo

Object-oriented iterator wrapper for Python

Description

iteroo provides a functional, object-oriented interface for working with iterators in Python. It wraps any iterable and exposes a rich set of methods for chaining, transformation, and collection, inspired by functional programming and modern iterator libraries.

  • Chainable, lazy iterator operations
  • Functional-style methods: map, filter, takewhile, dropwhile, flatten, etc.
  • Collect results as lists, sum, count, and more
  • 100% test coverage, MIT licensed

Features

  • it: Main iterator wrapper class
  • map, filter, enumerate, takewhile, dropwhile, flatten, pairwise, select, zip, cycle, diff, inmap, alltrue, allfalse, equal, allequal, sum, count, max, take_n, take_every_nth
  • Utility functions: range, count, repeat

Installation

pip install iteroo

Or for development:

uv pip install -e '.[test]'

Usage

from iteroo import it

# Basic usage
nums = it([1, 2, 3, 4, 5])
even = nums.filter(lambda x: x % 2 == 0).collect()  # [2, 4]

# Chaining
result = (
    it.range(10)
      .filter(lambda x: x % 2)
      .map(lambda x: x * 10)
      .take_n(3)
      .collect()
)
# result: [10, 30, 50]

# Flattening
nested = it([[1, 2], [3, 4]])
flat = nested.flatten().collect()  # [1, 2, 3, 4]

# Pairwise difference
seq = it([1, 4, 9, 16])
diffs = seq.diff().collect()  # [3, 5, 7]

# Inmap (apply multiple functions to each element)
a = it([[1, 1], [2, 2], [3, 3]])
b = a.inmap([lambda x: x + 1, lambda x: x + 2]).collect()  # [[2, 3], [3, 4], [4, 5]]

# Utilities
from iteroo.it import repeat
assert repeat('a', 3).collect() == ['a', 'a', 'a']

Testing

To run the tests and check coverage:

uv pip install -e '.[test]'
pytest --cov=src/iteroo --cov-report=term-missing

To generate an HTML coverage report:

pytest --cov=src/iteroo --cov-report=html
# Open htmlcov/index.html in your browser

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iteroo-0.0.1.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iteroo-0.0.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file iteroo-0.0.1.tar.gz.

File metadata

  • Download URL: iteroo-0.0.1.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.3

File hashes

Hashes for iteroo-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b31226596eebc2face0d316085a9b6fb9d969641733240d99a16e34f9c2b7004
MD5 bd867a0ac6860a2bb3cf5eea4129087d
BLAKE2b-256 83c456e4a04030fff809ed6a65cad7c8f4c51228095033a42a2f5d15dd905662

See more details on using hashes here.

File details

Details for the file iteroo-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: iteroo-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.3

File hashes

Hashes for iteroo-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c7031747041f2983b6304f7642fd12080162804defca8a2abaeb4948f1630841
MD5 4c4036682c2d8ee8b26c8cfe34af992f
BLAKE2b-256 6d0ed520ce117e51d9b49cfeadbabecb5a46b82bdaa017072299c5c1a05ae71b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page