Skip to main content

Assign attributes to functions using a decorator.

Project description

Last release Python version Documentation Test status Test coverage Last commit

FuncAttr provides a simple decorator that assigns attributes to functions. For example, if you have several different functions for analyzing the same data, you might use this library to give each a descriptive title to be used in downstream plotting routines. Of course, it isn’t difficult to assign attributes like these to functions without a decorator, but such assignments must happen after the function body and can be easy to lose track of. A decorator puts these labels at the beginning of the function, and can never be accidentally separated from the function as the code is refactored.

Installation

FuncAttr is available on PyPI:

$ pip install funcattr

Usage

Here’s how to use the decorator:

from funcattr import annotate

@annotate(title="Do Spam")
def do_spam():
    pass

print(do_spam.title)  # Do Spam

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

funcattr-0.0.0.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

funcattr-0.0.0-py2.py3-none-any.whl (2.8 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