Skip to main content

Reduce nested for i in range(n) loops to a single line

Project description

mrange

Install via pip install mrange

Import via from mrange import mrange

Description

mrange is used to remove nested range loops

Input:

n_s = (n_1, n_2, ..., n_m) Tuple of integers

Output:

Generator outputting len(n_s) values with every call, generating every combination of values in the intervals [0,1,...,n_s[i]-1]

Use:

for a, b, ..., m in mrange((n_a, n_b, ..., n_m)):
    ...
Replaces:
for a in range(n_a):
    for b in range(n_b):
       ...
           for m in range(n_m):
               ...

Authors:

By Michael Schilling, with the help of Francesco Preti

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

mrange-0.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

mrange-0.4-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file mrange-0.4.tar.gz.

File metadata

  • Download URL: mrange-0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for mrange-0.4.tar.gz
Algorithm Hash digest
SHA256 d4f679fdb83bb2924c31588615012d34842217b787e0d7cfed128b032fd0cf4d
MD5 400ee2d47d0e6497899318c89b76ac49
BLAKE2b-256 4ca0900ecd8b9ab403e296f97cf9532960c3fd33a6ec0bc09e1efd8484a10965

See more details on using hashes here.

File details

Details for the file mrange-0.4-py3-none-any.whl.

File metadata

  • Download URL: mrange-0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for mrange-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 82f5666e9ff8b7091b3aad99438c16923a8e42c1acca24311b73c0f8b502be01
MD5 43b450d78e9ed58c9af614687278a608
BLAKE2b-256 f7ab91442a77a30b60831fdc91de9965d1369d8fe784af2f998913c6e076bb79

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