You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eaterate *(eet-uh-rate)* is a toolkit of modern Python iterators. Or whatever the hell you wanna call this.
6
+
7
+
**Key features**:
8
+
9
+
-**Fully typed**. C'mon, type annotations are just essential these days.
10
+
-**Quick protyping**. Just chain everything.
11
+
-**Flexible**. Build your custom iterators.
3
12
4
13
```python
5
14
from eaterate import eater
6
15
7
-
eat = eater("hi!").chain("yes")
16
+
eat = eater("hi!").enumerate()
8
17
9
-
forcin eat:
10
-
print(c)
18
+
forindex, charin eat:
19
+
print(index, char)
11
20
12
21
# Output:
13
-
# h
14
-
# i
15
-
# !
16
-
# y
17
-
# e
18
-
# s
22
+
# 0 h
23
+
# 1 i
24
+
# 2 !
25
+
```
26
+
27
+
## Quick tour
28
+
With `eaterate`, you can use iterators in the easiest way possible:
29
+
30
+
```python
31
+
eat = (
32
+
eater([1, 2])
33
+
.chain([4, 5])
34
+
.map(lambdai: i *2)
35
+
)
36
+
37
+
# collects to a list
38
+
print(eat.collect(list))
39
+
40
+
# [2, 4, 8, 10]
19
41
```
42
+
43
+
You can also add separators to your iterator like never before (kind of):
44
+
45
+
```python
46
+
eat = eater([1, 2, 3]).intersperse(500)
47
+
for i in eat:
48
+
print(i)
49
+
50
+
# Output:
51
+
# 1
52
+
# 500
53
+
# 2
54
+
# 500
55
+
# 3
56
+
```
57
+
58
+
There are a lot more features to try out! Refer to the [Core API](./core.md) reference for more!
59
+
60
+
## Architecture
61
+
62
+
Instead of raising `StopIteration` (exception-like) when an iterator ends, `eaterate` uses value wrappers, specifically [`Option[T]`](./utilities.md#eaterate.Option).
0 commit comments