Skip to main content

No project description provided

Project description

Dollop

A python package for splitting up iterables into smaller portions 🥣.

Usage

Supports:

  • Sequences: list, tuple, str, range, bytes, bytearray or any other sequence-like object.
  • Pandas objects: DataFrame, Series.
  • Files: either as a file path or handle.

Example usage (automatically checks object type):

from dollop import serve

dollops = serve(items, serving_size=10)

for dollop in dollops:
    do_something(dollop)

The serving_size parameter defines how many items/lines/characters/etc. you want in each dollop!

To use type-specific dollop:

  • Sequences: from dollop.sequence import serve.
  • Pandas: from dollop.pandas import serve
  • Files: from dollop.file import serve.

For dollop.file you can specify mode=lines or mode=chars to read the file line-by-line or character-by-character.

See also

The more_itertools and later (Python 3.12+) itertools packages have something similar:

from more_itertools import chunked

chunks = chunked(iterable, n))

and

from itertools import batched

batches = batched(iterable, n))

These both have the disadvantage that typing is not preserved.

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

dollop-1.0.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dollop-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file dollop-1.0.0.tar.gz.

File metadata

  • Download URL: dollop-1.0.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for dollop-1.0.0.tar.gz
Algorithm Hash digest
SHA256 15658543bb8b60430b17640097affceadcd4b81f43e18bb1c023072700a47ced
MD5 1554bdc3494221c156b0669dfacd435d
BLAKE2b-256 9af4ad5d31afeb26c2e2b1254a85a4e0327461a860a8c49083953ecabe4074bf

See more details on using hashes here.

File details

Details for the file dollop-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dollop-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for dollop-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27b2a4b15955f1a7dc4aea473e00ae66072939d65cb80651c612e465145798c3
MD5 d648aa58179e82bbe9b99591a85d8964
BLAKE2b-256 92bf959c43849fb86d445aacb7674fd19323a9351e437ef47413616ec50446aa

See more details on using hashes here.

Supported by

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