Proxy list to a list-returning function
Project description
This small package provides a proxy list to a list-returning function:
>>> from lazylist import LazyList >>> l = LazyList(lambda: x) >>> x = [1, 2, 3] >>> list(l) [1, 2, 3]
More precisely, view function doesn’t have to return an exact list, but an any squence object e.g. str, tuple:
>>> x = "hello" >>> list(l) ['h', 'e', 'l', 'l', 'o']
It satisfies collections.abc.Sequence protocol:
>>> from collections import Sequence >>> isinstance(l, Sequence) True >>> l[-1] 'o' >>> len(l) 5
However, it doesn’t satisfy collections.abc.MutableSequence protocol. In other words, it’s immutable:
>>> from collections import MutableSequence >>> isinstance(l, MutableSequence) False >>> l[0] = 'H' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'LazyList' object does not support item assignment
Distributed under LGPLv3 or higher.
Todos
LazySet
LazyMap
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
lazylist-0.9.0.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for lazylist-0.9.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a04be55176997956387e0705823d822e0031a5d787fb1e792787ed1fd07f5ba6 |
|
MD5 | bc2de977e2ae67f4e5a4ea21f18d9991 |
|
BLAKE2b-256 | 75ebdc3c807c2d0638898b3f57d2f57d3c044876ba6548cb66be488d1b0bbee3 |