Skip to main content

enumerate extended to support manual advancement or skipping of the index

Project description

This package provides 2 iterators, enumerate_skip and enumerate_manual, that extend the behaviour of the standard libraries enumerate a bit.

enumerate_skip has been extended with a skip method that makes sure the next index yielded is the same as the current one. The word skip might not make sense at first, but this function was written because I needed to not handle some values yielded by an iterator, like:

for index, obj in enumerate(...):
    if obj.has_some_attr():
        continue
    # do something with object and index here

If index in that example was printed to the user (or something similar), there would be gaps. Using enumerate_skip instead, the above example could be written as:

it = enumerate_skip(...)
for index, obj in it:
    if obj.has_some_attr():
        it.skip()
        continue
    # do something with object and index here

enumerate_manual works the other way around: you have to manually call advance on it to increment the index:

it = enumerate_manual(...)
for index, obj in it:
    if obj.has_some_attr():
        continue
    # do something with object and index here
    it.advance()

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

enumerate_skip-1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

enumerate_skip-1.0-py2.py3-none-any.whl (4.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file enumerate_skip-1.0.tar.gz.

File metadata

File hashes

Hashes for enumerate_skip-1.0.tar.gz
Algorithm Hash digest
SHA256 c1ad838c822720abe43371ff273ca0f09697850e380b55432bba6162f2c5a04c
MD5 b6f9beb3072b2dde35e82dd613e97517
BLAKE2b-256 17f17dd0a1b56a859d7decf1fde685a76cea6fcc348c380f8f21d651d4a3c9e5

See more details on using hashes here.

File details

Details for the file enumerate_skip-1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for enumerate_skip-1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 32fca0f017027ca631b1195abbd4fa03d34929d32508170f15fa805bb02136c7
MD5 c6cc377ecbdb75d5d1a59ad3433e0c5e
BLAKE2b-256 ed4b731d4c8a99e01d1f0eb4faa8aeea39ac685b07f31bee1ef270f62ca7cbbb

See more details on using hashes here.

Supported by

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