IterWrapper
This is a wrapper for python iterators to give it a style like those in Rust among with other methods, to improve the consistency and code readablity of iterator manipulation.
A example for this is something like :
from iterwrapper import IterWrapper as iw
l = (
iw(range(0,10))
.map(lambda x:x+1)
.filter(lambda x:x%2==0)
.fold(lambda c, x: c+x**2, d=0)
)
print(l) # 220 = 2^2 + 4^2 + 6^2 + 8^2 + 10^2
comparing to the equivalent representation in vanilla python :
l = sum(map(lambda x: x**2, filter(lambda x:x%2==0, map(lambda x: x+1, range(0,10)))))
# or
r = range(0, 10)
m = map(lambda x: x+1, r)
f = filter(lambda x: x%2==0, m)
c = map(lambda x: x**2, f)
l = sum(c)
Another one:
from iterwrapper import IterWrapper as iw
l = (
iw(range(0,10))
.map(lambda x: x+1)
.filter(lambda x: x%2==0)
.map(str)
.collect(', '.join)
)
print(l) # "2, 4, 6, 8, 10"
# Comparing to
l = ', '.join(map(str, filter(lambda x: x%2==0, map(lambda x: x+1, range(0,10)))))
# or
r = range(0, 10)
m = map(lambda x: x+1, r)
f = filter(lambda x: x%2==0, m)
ms = map(str, f)
l = ', '.join(ms)
The main goal of this only is to be a convenient wrapper to manipulate iterators, so it comes with high compatibility since most of the method is done by accessing the wrapped iterator, and most of the method just use the wrapper as a container.
Metadata
Release files for iterwrapper 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| iterwrapper-0.1.4.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iterwrapper-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.6 kB
Release files / iterwrapper-0.1.4.tar.gz
| Download URL | iterwrapper-0.1.4.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2dd1e5a55935a0ce151912524de1781d2aa9cb1fda3e2424fb403ff857f63d9
|
|
BLAKE2b-256 checksum How to use checksums |
8214e4ece51ce39f268d63cb7d9197478b3ff971e156f2da7d2d5e17396c0d4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.10
|
Release files / iterwrapper-0.1.4-py3-none-any.whl
| Download URL | iterwrapper-0.1.4-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3296d81fa2e558734f572617487fb6be3e2af12af2776899dd29d2154ffdba5
|
|
BLAKE2b-256 checksum How to use checksums |
5a6026365ea984386b255e9a4b5c6fa014ba668b14251e0728e2a9a8cc5f8ad0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.20.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.10
|