Decorator to convert a class into an iterable.
Project description
Iterable decorator
Create iterable classes using a class decorator.
Values added to an iterable class are sored in the class's self.args
attribute as a tuple
of whatever type you have provided.
Examples
from iterables import iterable
@iterable
class Items:
# You can type annotate your iterable like so:
item: str
# Note that this has no real effect on the generation of the iterable.
items = Items("Hello", "iterables!")
for item in items:
print(item)
>>> "Hello"
>>> "iterables!"
You can attach additional methods to an iterable as you would with a dataclass.
from iterables import iterable
@iterable
class Items:
item: str
@classmethod
def from_list(data: list[str]):
return cls(*data)
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
File details
Details for the file iterables-decorator-0.1.1.tar.gz
.
File metadata
- Download URL: iterables-decorator-0.1.1.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0040c8338c29efb3dcd8b0163a3d8a785f695a71263913a25735e67443964fe5 |
|
MD5 | f08806831131799bdfc2c06ba8600f9c |
|
BLAKE2b-256 | bc5e121bd795f8865b83035c737242105ce5cddaa0b31ebf49982110a7da72c7 |
File details
Details for the file iterables_decorator-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: iterables_decorator-0.1.1-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd7d03588fd05261d5c55eb35f40b515ca5fd86759e0f6bfb03e863237f3209e |
|
MD5 | b98b5787255fa84601a1666e9716064a |
|
BLAKE2b-256 | 0d4d8d321e5d001652389fd5a3df5f807fbbe6fa87ab16fce8c04607beebf11b |