Assign attributes to functions using a decorator.
Project description
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
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
Hashes for funcattr-0.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fef770d80ebd208dfc14c273a337eae779ddc5aee89eb81a2a82be0d84744c50 |
|
MD5 | 90dbf3ea4d3037f82f037e729c94fd1a |
|
BLAKE2b-256 | 3ce50d2c74c93a707f8bd2e781f082db7db63caf36ee2d7da7e597c8f7a79980 |