Composable external iteration.
If you have found yourself with acollectionof some kind, and needed to perform an operation on the elements of said collection, you will quickly run intoiterators. Iterators are heavily used in idiomatic Python code, so becoming familiar with them is essential.
Python 3.8 or above is required.
Installing the library withpip
is quite simple:
$pip install iters
Alternatively, the library can be installed from source:
$git clone https://github /nekitdev/iters.git
$cditers
$Python -m pip install.
You can additers
as a dependency with the following command:
$poetry add iters
Or by directly specifying it in the configuration like so:
[tool.poetry.dependencies]
iters="^0.18.0"
Alternatively, you can add it directly from the source:
[tool.poetry.dependencies.iters]
git="https://github /nekitdev/iters.git"
Squaring only even numbers in some sequence:
fromitersimportiter
defis_even(value:int)->bool:
returnnotvalue%2
defsquare(value:int)->int:
returnvalue*value
numbers=[0,1,2,3,4,5,6,7,8,9]
result=iter(numbers).filter(is_even).map(square).list()
print(result)# [0, 4, 16, 36, 64]
Asynchronous iteration is fully supported byiters
,and its API is similar to its
synchronous counterpart.
You can find the documentationhere.
If you need support with the library, you can send anemail or refer to the officialDiscord server.
You can find the changeloghere.
You can find the Security Policy ofiters
here.
If you are interested in contributing toiters
,make sure to take a look at the
Contributing Guide,as well as theCode of Conduct.
iters
is licensed under the MIT License terms. SeeLicensefor details.