Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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()
Release History

Release History

This version
History Node

1.0

History Node

0.2

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
enumerate_skip-1.0-py2.py3-none-any.whl (4.8 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Mar 2, 2015
enumerate_skip-1.0.tar.gz (3.7 kB) Copy SHA256 Checksum SHA256 Source Mar 2, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting