Skip to main content

A simple decorator to enable Swift-like argument labels for Python functions.

Project description

arglabels

Build Status License: MIT

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.

Files for arglabels, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size arglabels-0.0.6.tar.gz (1.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page