Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memiter-0.1.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

memiter-0.1.1-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page