Skip to main content

BePosPliz (be positional please) is a lightweight module to anonymize the arguments of a function.

Project description

BePosPliz

BePosPliz (be positional please) is a lightweight module to anonymize the arguments of a function.

Relevant PEP: https://peps.python.org/pep-0646

I am not really sure if this has a real world purpose, but playing with new Python features is very enjoyable. I appreciate the effort to improve type expressiveness, and I am looking forward to PEPs 695 and 696 for even more fun :D

Features

anon_args

Usage

Let the following function:

from bepospliz import anon_args

@anon_args
def div(a: int, b: int) -> float:
    """Divide a by b"""
    return a / b

div's original signature is div(a: int, b: int) -> float.

div without decorator

With the decorator @anon_args, it becomes div(int, int) -> float, meaning that it cannot be called by specifically naming the args anymore (e.g. div(b=3, a=2))

div with the decorator


Signature

anon_args(function: Callable[[*Ps], R]) -> Callable[[*Ps], R]

with Ps being the set of types of function's arguments, and R its return type.

Example

Given the previous div function, Ps would be (int, int) and R would be float.

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

bepospliz-1.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

bepospliz-1.0.1-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page