A simple decorator to enable Swift-like argument labels for functions.
Project description
arglabels
A simple decorator to enable Swift-like argument labels for 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:
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
arglabels-0.0.2.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for arglabels-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21b2c6cb2b57c582b53bd41ac0522f281324c0891b179e7f74073ecb2d218b81 |
|
MD5 | b298caf871508c6171325684cf02684e |
|
BLAKE2b-256 | 2de5878ff9505ad86c7caa0ba3c02e6fa4a312e0931b384b40c957a10a7944cd |