A simple decorator to enable Swift-like argument labels for Python functions.
Project description
arglabels
A simple decorator to enable Swift-like argument labels for Python functions.
It re-labels certain keyword arguments, so that your function parameters can have an external and an internal name like argument labels and parameter names in Swift.
Installation
Install from PyPI with:
pip install arglabels
Usage
If you have a function like the following:
def invite(name, activity):
return f"Hey {name}! Would you like to go {activity}?"
When calling that function it would be nice to have a syntax that almost reads like plain english, for example:
invite("Alex", to_go="fishing")
You can achieve this with the arglabels decorator, by using it on the function definition like so:
from arglabels import arglabels
@arglabels(activity="to_go")
def invite(name, activity):
return f"Hey {name}! Would you like to go {activity}?"
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
File details
Details for the file arglabels-0.0.6.tar.gz
.
File metadata
- Download URL: arglabels-0.0.6.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f95feb2ae04a7196745890b909c0c64fede523044cf1f303a9cbd9d1fe6c211 |
|
MD5 | 5bb0a1ef3f3117043d630cbe2a7ae30a |
|
BLAKE2b-256 | f8e60be5ab8b6a32e51d202b3bbcce4d982517f75f90c5db39f1f9c86d9c2888 |