Add a RepeatableIterable type and a function to obtain it
Project description
python-repeatable-iterable
A new type RepeatableIterable for Python and a way to obtain one instance
Since in Python an Iterator is an Iterable and that you cannot iterate multiple times on an iterator, you may encounter WTF bugs, even with type checking. This package provides possible solutions to this problem. See here for a discussion on this problem: https://stackoverflow.com/questions/63104689/what-is-the-pythonic-way-to-represent-an-iterable-that-can-be-iterated-over-mult
Before:
def foo(iterable: Iterable):
for that in iterable:
bar(that)
for that in iterable:
# possible bug
baz(that)
foo(something)
After solution 1:
from python_repeatable_iterable import RepeatableIterable, get_repeatable_iterable
def foo(iterable: RepeatableIterable):
for that in iterable:
bar(that)
for that in iterable:
baz(that)
something_else = get_repeatable_iterable(something)
foo(something_else)
After solution 2:
from python_repeatable_iterable import get_repeatable_iterable
def foo(iterable: Iterable):
iterable = get_repeatable_iterable(iterable)
for that in iterable:
bar(that)
for that in iterable:
baz(that)
foo(something)
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
Close
Hashes for python_repeatable_iterable-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea9a02471fdb99be925fac27123828010c6bdc0ccbf2bd48b40e762bdf19fca4 |
|
MD5 | b4fc82720103a591f06f6d058031b2f9 |
|
BLAKE2b-256 | ae6f1cd1cd32f31b9eb59d203aa6c4c34b086b7850dff0efe0d0816ff257c7a1 |
Close
Hashes for python_repeatable_iterable-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 018ba8697583c03bff482bd5a98e1518a68667c16d9363b7350f0560dc2a424f |
|
MD5 | ed4acea9d85aeaa6e88d311519dbfb98 |
|
BLAKE2b-256 | a768d43ac7791b1be3fd1fddf00019b3a759d4b59c446db27ff3c74660f0ab8d |