Micro library providing generates decorator
Project description
Generates is a micro library providing generates decorator.
The generates decorator can be used to easily create a function that returns a container like list or dict, but using generator syntax in the function body. For example:
@generates(list) def get_numbers(n): for i in range(n): yield i assert get_numbers(5) == [0, 1, 2, 3, 4] @generates(dict) def get_map(): yield ('key1', 'value1') yield ('key2', 'value2') assert get_map() == {'key1': 'value1', 'key2': 'value2'}
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
generates-0.1.0.tar.gz
(1.5 kB
view hashes)
Built Distribution
Close
Hashes for generates-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5fca8bef0bb9368f1d51fb14896892e6f274a81d8bfbe49a88ac52a133031eb |
|
MD5 | 9b75735b17be8a2b80801b96e6cccb84 |
|
BLAKE2b-256 | be4474833b56929ee2b27fd6032fe5806f5018420d26cb3770409eecfcf3ffd3 |