Extends the peekable class from more-itertools
Project description
more-peekable
An extension of the peekable class from more-itertools. Adds
methods from Rust's peekable struct, easier support for subscripted
type annotations, and another dependency to your project.
Usage
Install with pip install more-peekable.
from more_peekable import Peekable
less_than_five = lambda n: n < 5
numbers = Peekable(range(10))
# Read every number up through five, without consuming the last
for number in numbers.take_while(less_than_five):
assert number < 5
# Check the next number without consuming it
assert numbers.peek() == 5
# Check before consuming the next number, 5
assert numbers.next_if_eq(5) is not None
# Consume the next number, 6,
assert next(numbers) == 6
Contributing
pip install -r requirements-dev.txt
pre-commit install
See Makefile for build process.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file more_peekable-0.1.0.tar.gz.
File metadata
- Download URL: more_peekable-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
511a13af9f52c78420901d63944490d1ed3625742d7ddd89b2ae3756f519e8f8
|
|
| MD5 |
c308d4a369965407877a8c4dad93fe82
|
|
| BLAKE2b-256 |
931287c052f44d010da6cff15cabae6d700255487090135f4c86267084aaf4f6
|
File details
Details for the file more_peekable-0.1.0-py3-none-any.whl.
File metadata
- Download URL: more_peekable-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11d9f58625dab938bd7f777d1368bc80a1191a81a299553f291091bb577ef1c0
|
|
| MD5 |
af7f3ad0ec475ef2f39cf2f4cba0a995
|
|
| BLAKE2b-256 |
5dd53bb596db9abaffcf4a866231822232097ec986f7479b90137a0dc6993000
|