Wimpy

0.6 · active · verified Thu Apr 16

Wimpy is a Python utility library (anti-copy-pasta) containing commonly used helper functions that the author extracted to avoid repeatedly copying them into new projects. It provides a collection of small, general-purpose utilities for everyday Python programming tasks. The library is currently at version 0.6 and is actively maintained, with releases focusing on adding new features and improving existing ones.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates stripping prefixes, checking for subsequences, and creating overlapping chunks from an iterable, which are core utilities provided by the library.

from wimpy import strip_prefix, is_subsequence, chunks

# Example 1: Stripping prefixes
text = "hello_world"
stripped_text = strip_prefix(text, "hello_")
print(f"Original: {text}, Stripped: {stripped_text}")

# Example 2: Checking for subsequence
sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sub = [2, 5, 8]
is_sub = is_subsequence(sub, sequence)
print(f"Is {sub} a subsequence of {sequence}? {is_sub}")

# Example 3: Chunking an iterable
data = list(range(10))
chunk_size = 3
overlap = 1
result_chunks = list(chunks(data, chunk_size, overlap))
print(f"Original data: {data}, Chunks (size={chunk_size}, overlap={overlap}): {result_chunks}")

view raw JSON →