Skip to main content

Replace common looping boilerplate with pretty method chaining.

Project description

tests

Welcome to loop

Replace common looping boilerplate with pretty method chaining.

Installation

pip install loop-python

Documentation

Visit the documentation site.

Example

Loop over range(20), apply the fibo() function and then, on top of it, apply the fizzbuzz() function, finally, apply print():

from loop import loop_over


def fizzbuzz(x):
    rules = {3: 'fizz', 5: 'buzz'}.items()
    res = ''.join(word for div, word in rules if x%div == 0)
    return res if res else x


def fibo(x):
    a, b = 1, 1
    for _ in range(1, x):
        a, b = b, a + b
    return b


loop_over(range(20)).map(fibo).map(fizzbuzz).map(print).exhaust()

Will produce the following output:

1
1
2
fizz
buzz
8
13
fizz
34
buzz
89
fizz
233
377
buzz
fizz
1597
2584
4181
fizzbuzz

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

loop-python-0.2.3.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

loop_python-0.2.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file loop-python-0.2.3.tar.gz.

File metadata

  • Download URL: loop-python-0.2.3.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for loop-python-0.2.3.tar.gz
Algorithm Hash digest
SHA256 757fb6afed3bec52cc686862454cdfb8ca284607dba9ac0f968817b8ada3d8c1
MD5 3af1023213ce742e1d45f3fe456a10e9
BLAKE2b-256 de72ba7ede51cc86db922dc05bfd19523274f0bd15618322e548463d3de79b98

See more details on using hashes here.

File details

Details for the file loop_python-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: loop_python-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for loop_python-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eeb39214a1a3c3932e987770bff5e0df8cd302542a7fd4219a416aee211bd86d
MD5 fb376a1ca50069c74d67e42fe6108935
BLAKE2b-256 75cdc9dfcf7fb9eb1a271d1ac7ebf447f1fa7f50d22665dcd38dd8c633ae8046

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