Skip to main content

Yet another iterator utils lib

Project description

# iterage

toolset for python iterators and generators

## iterator operations

Documentation of iterage functions and python standard library functions for do things with iterators and generators.

### reduce

#### any / iterage.reduce.iany

To check if at least one element is true, use the any built-in function:

any([True, False, False]) # -> True any([False, False, False]) # -> False

l = [0, 1, 14] any(x > 10 for x in l) # -> True any(x < 0 for x in l) # -> False

# iterage iterage.reduce.iany(l, lambda x: x > 10) # -> True

#### all / iterage.reduce.iall

To check if all elements are true:

all([True, True, True]) # -> True all([True, False, True]) # -> False

l = [0, 1, 14] any(x >= 0 for x in l) # -> True any(x < 0 for x in l) # -> False

# iterage iterage.reduce.iall(l, lambda x: x >= 0) # -> True

#### not any / iterage.reduce.inone

To check if no element is true:

not any([False, False, False]) # -> True not any([True, False, True]) # -> False

l = [0, 1, 14] not any(x >= 0 for x in l) # -> False not any(x < 0 for x in l) # -> True

# iterage iterage.reduce.inone(x < 0 for x in l) # -> True

#### iterage.reduce.iempty

Check if iterable is empty:

iterage.reduce.iempty(x < 0 for x in [0,1,2,3]) # -> True iterage.reduce.iempty(x > 1 for x in [0,1,2,3]) # -> False

#### iterage.reduce.icount

Count elements:

iterage.reduce.icount(range(4)) # -> 4

#### iterage.reduce.icount_if

Count true elements:

iterage.reduce.count_if([True, False, False]) # -> 1

iterage.reduce.count_if(x > 1 for x in [0,1,2,3]) # -> 2

# alternative sum(1 for x in [0,1,2,3] if x > 1) # -> 2 iterage.reduce.icount(x for x in [0,1,2,3] if x > 1) # -> 2

## similar tools

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

iterage-0.1.dev0.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

iterage-0.1.dev0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file iterage-0.1.dev0.tar.gz.

File metadata

  • Download URL: iterage-0.1.dev0.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.7

File hashes

Hashes for iterage-0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 476c77c43915d413d34617feb30c743d6a34b7e8d6b9c3f83468c3fb70a358c5
MD5 7d520ecc8444e14b53c9b56491bb82a6
BLAKE2b-256 6f027c4b98170e72ca49c092c2392e26b0934675b6a5a9eec742107c6a2436bf

See more details on using hashes here.

File details

Details for the file iterage-0.1.dev0-py3-none-any.whl.

File metadata

  • Download URL: iterage-0.1.dev0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.21.0 CPython/3.6.7

File hashes

Hashes for iterage-0.1.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b15eafc6bae2e6e9cc120c5b2aa15cf714973a6f1422c608b327b6b62079d42
MD5 aa7db160e8fe123021f1f5e9b04b608b
BLAKE2b-256 5656d5aa947ffab65388f7bbbbacb4c6f6092d8243db9840f8ac8dcca6ef25a0

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