Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.012s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.010s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
IterProxy
✓ from iterproxy import IterProxy
This example demonstrates how to wrap a standard Python iterable with `IterProxy` and use its extended API for accessing elements, including `.one()`, `.many()`, `.skip()`, `.all()`, and `.one_or_none()`. It also shows how to chain multiple filter operations or combine them in a single call.
from iterproxy import IterProxy
# Create an IterProxy from any iterable
my_list = list(range(10))
proxy = IterProxy(my_list)
# Access elements using ORM-like API
print(f"First element: {proxy.one()}") # Output: First element: 0
print(f"Next three elements: {proxy.many(3)}") # Output: Next three elements: [1, 2, 3]
# Skip elements and get subsequent ones
# Note: This operates on the *remaining* elements after previous calls
print(f"Skip 2, get next 2: {proxy.skip(2).many(2)}") # Output: Skip 2, get next 2: [6, 7]
# Get all remaining elements
print(f"All remaining elements: {proxy.all()}") # Output: All remaining elements: [8, 9]
# Handle potentially empty results gracefully
empty_proxy = IterProxy([])
print(f"One or none from empty: {empty_proxy.one_or_none()}") # Output: One or none from empty: None
# Chaining filter operations
def is_odd(x): return x % 2 == 1
def gte_5(x): return x >= 5
# Re-create proxy for fresh iteration
proxy_for_filter = IterProxy(range(10))
filtered_items = proxy_for_filter.filter(is_odd).filter(gte_5).all()
print(f"Filtered (odd and >=5): {filtered_items}") # Output: Filtered (odd and >=5): [5, 7, 9]
# Multiple filter functions in one call (implicit AND logic)
proxy_combined_filter = IterProxy(range(10))
combined_filtered_items = proxy_combined_filter.filter(is_odd, gte_5).all()
print(f"Combined filter (odd and >=5): {combined_filtered_items}") # Output: Combined filter (odd and >=5): [5, 7, 9]
Errors
Common errors & fixes
AttributeError: 'list' object has no attribute 'one'
Developers attempt to use iterproxy methods like .one() directly on standard Python iterables (e.g., lists) without first wrapping them with the IterProxy class.
fixfrom iterproxy import IterProxy
my_list = [1, 2, 3]
proxy = IterProxy(my_list)
result = proxy.one()
ValueError: Sequence contains no items
The `.one()` method was called on an `IterProxy` instance whose underlying iterable was empty, which `iterproxy` explicitly raises as an error in such cases.
fixfrom iterproxy import IterProxy
proxy = IterProxy([])
result = proxy.one_or_none() # Use .one_or_none() to return None if the sequence is empty
NameError: name 'IterProxy' is not defined
The main `IterProxy` class, which is the primary entry point for the library, was used in the code without being explicitly imported from the `iterproxy` package.
fixfrom iterproxy import IterProxy
proxy = IterProxy([1, 2, 3])
ModuleNotFoundError: No module named 'iterproxy'
The `iterproxy` library is not installed in the current Python environment or the active environment does not include it.
Upgrade
Version history
0.3.1latest on PyPI · released Nov 2, 2023
Audit
Dependencies
No dependency data recorded yet.