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 Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page