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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file funcattr-0.0.0.tar.gz.
File metadata
- Download URL: funcattr-0.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2d15716861702aadaddeecbc7bae85d67d9ea57928cc91e8432267dff551ff0
|
|
| MD5 |
cb79e0fbcd644db47f24ddf7dbd4d0a1
|
|
| BLAKE2b-256 |
323e5b02eeaca57b857c3d2b9566177f84a37bdd2539986a3e67ecbcfb34162a
|
File details
Details for the file funcattr-0.0.0-py2.py3-none-any.whl.
File metadata
- Download URL: funcattr-0.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fef770d80ebd208dfc14c273a337eae779ddc5aee89eb81a2a82be0d84744c50
|
|
| MD5 |
90dbf3ea4d3037f82f037e729c94fd1a
|
|
| BLAKE2b-256 |
3ce50d2c74c93a707f8bd2e781f082db7db63caf36ee2d7da7e597c8f7a79980
|