Skip to content

Commit 9b896cd

Browse files
committed
yes
1 parent b2d9038 commit 9b896cd

File tree

2 files changed

+56
-13
lines changed

2 files changed

+56
-13
lines changed

README.md

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,62 @@
1-
# eaterate
2-
Modern Python iterators. With a Rust-like syntax, hell nawh.
1+
# Eaterate
2+
3+
[GitHub](https://github.com/AWeirdDev/eaterate)[Docs](https://aweirddev.github.io/eaterate)
4+
5+
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.
312

413
```python
514
from eaterate import eater
615

7-
eat = eater("hi!").chain("yes")
16+
eat = eater("hi!").enumerate()
817

9-
for c in eat:
10-
print(c)
18+
for index, char in eat:
19+
print(index, char)
1120

1221
# 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(lambda i: i * 2)
35+
)
36+
37+
# collects to a list
38+
print(eat.collect(list))
39+
40+
# [2, 4, 8, 10]
1941
```
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).

eaterate/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ def next(self) -> Option[int]:
201201
`Option.none()` if the iteration should stop.
202202
"""
203203
raise NotImplementedError(
204-
"`Eaterator` should be implemented manually.\n"
205-
"See https://aweirddev.github.io/eaterate/ for more."
204+
"`next()` should be implemented.\n"
205+
"See https://aweirddev.github.io/eaterate/custom for custom iterators."
206206
)
207207

208208
def next_chunk(self, n: int, *, strict: bool = False) -> list[T]:

0 commit comments

Comments
 (0)