Skip to main content

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


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)

Uploaded source

Built Distribution

generates-0.1.0-py2.py3-none-any.whl (3.7 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page