Skip to main content

I love enumerate(), but I hate using it with zip() - this function takes care of it

Project description

I love enumerate(), but I hate using it with zip() - this function takes care of it

pip install enummi

Tested against Windows 10 / Python 3.10 / Anaconda

Combining multiple iterables:

It allows you to merge multiple iterables into a single sequence of tuples. This can be useful when you have several related iterables and want to process them together.

Indexing the tuples:

The function assigns an index value to each tuple, representing the position of the elements in the original iterables. This indexing provides a convenient way to access and reference elements based on their relative positions.

Generates results on the fly:

As a generator function, enummi generates and yields results one at a time, as they are needed. This lazy evaluation strategy can save memory and computational resources, especially when dealing with large or infinite sequences.

Flexibility with input:

The function accepts a variable number of iterables as arguments (*args), allowing you to provide any number of iterables to be combined. It can handle different lengths of input iterables and adapt accordingly.

Compatible with different iterable types:

The function can work with various types of iterables, such as lists, tuples, strings, or any other iterable object. It is not limited to a specific data structure, providing flexibility in terms of input.

Simple and concise implementation:

The implementation of enummi is relatively straightforward and concise, utilizing built-in Python functions (zip and enumerate) to achieve the desired functionality. This simplicity makes the function easy to understand and maintain.

from enummi import enummi

for i, a, b, c in enummi([1, 2, 3], [4, 5, 6], [7, 8, 9]):
  print(i, a, b, c)
Output:
  0 1 4 7
  1 2 5 8
  2 3 6 9

for i, a in enummi([1, 2, 3]):
  print(i, a)
Output:
  0 1
  1 2
  2 3

for i, a in enummi([]):
  print(i, a)
Output:
  (no output)

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

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

Source Distribution

enummi-0.10.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

enummi-0.10-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file enummi-0.10.tar.gz.

File metadata

  • Download URL: enummi-0.10.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for enummi-0.10.tar.gz
Algorithm Hash digest
SHA256 6fabfff8c8529e07feb3fc781e84287e9213cba68e6f00ff6616e1c50046e2a5
MD5 9cc562d429b76d8deb1a5514c7fc17a6
BLAKE2b-256 b953c2e7c9e8f1a0fbfc82d72377f5c5b9eb97ef47bca65c6d094dc73a199366

See more details on using hashes here.

File details

Details for the file enummi-0.10-py3-none-any.whl.

File metadata

  • Download URL: enummi-0.10-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for enummi-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 ba7386c1e0a2dbe54c59bbd4c281e7f74d3217778e3ab2784643165879e19e99
MD5 37a7e5b896ac34f992254072cf3eacaf
BLAKE2b-256 e9b2c6917a0209d4a38ebe64c335f4b748ece6d912e78c6d36b46b5fd4ad9f97

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