A generator that extends the functionality of a generator. simplifying pagination and data access.
Project description
memiter
memiter
is a Python library that enhances the functionality of generators, making pagination and data access simpler and more intuitive.
It allows users to limit the number of elements generated, set the current page for pagination, and access the data that has been generated as many times as needed.
Additionally, it keeps the original generator, allowing the data to be generated again in a different configuration.
Features
- Pagination: Easily paginate through large datasets by setting limits and pages.
- Data Access: Access the generated data multiple times without re-running the generator.
- Flexibility: Keep the original generator for re-generation of data with different parameters.
Installation
Requirements:
- Python 3.8+
To install memiter
, simply use pip:
pip install memiter
Quick Start
Here's a quick example to get you started:
from memiter import memiter
# Create a memiter instance from a range generator
my_gen = memiter(range(100)).limit(5).page(2)
# Generate and access the data
print(list(my_gen))
# Output: [5, 6, 7, 8, 9]
# Access the data that has been generated
print(my_gen.data)
# Output: [5, 6, 7, 8, 9]
Usage
Creating a Memiter Instance
You can create a memiter instance from any iterable:
from memiter import memiter
my_gen = memiter(range(100))
Hurray! Your memiter instance is now ready to be used!
By default, the memiter instance will generate all the data from the original generator.
But if you want your can enhance the functionality of your generator by using the following methods:
Pagination
Limit the number of elements and set the current page:
- limit - Set the number of elements to generate.
- page - Set the current page for pagination.
my_gen.limit(5).page(2)
Iterating Over Data
like any other generator, you can iterate over the data generated by the memiter instance:
for data in my_gen:
print(data)
Accessing Data
memiter allows you to access the data that has been generated multiple times without re-running the generator.
You can access the data that has been generated using the data attribute:
print(my_gen.data)
License
memiter is licensed under the MIT License - see the LICENSE file for details.
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
File details
Details for the file memiter-0.2.0.tar.gz
.
File metadata
- Download URL: memiter-0.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c02682a29b32c5553e397101698c3d60c0265a568e8a1cb0366ff0a9d5f32b9 |
|
MD5 | ae00f891f9b1fc23c586001da02f8524 |
|
BLAKE2b-256 | c5ce1303a9578fdc12e2a63a9f2b3bd2eb8bfb15f13caba607b7e6c761c35031 |
File details
Details for the file memiter-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: memiter-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02aeac8de0cc6a2d7459dcc1150e3dad949b6e43050947f17aca21e76ce6b102 |
|
MD5 | a2ed38430939fbb694b50eab843c0e91 |
|
BLAKE2b-256 | 2bfe669e8a6a0eea1e5d953b81b36ca0f62311315a9f156853b9d6f0c6e93d7b |