No project description provided
Project description
This module defines a decorator to wrap legacy APIs. The primary use case is APIs defined before keyword-only parameters existed.
>>> from legacy_api_wrap import legacy_api
We have a function with many positional parameters lying around:
>>> def fn(a, b=None, d=1, c=2): ... return c, d, e
We want to convert the positional parameters d and c to keyword-only, change their order and add a parameter. For this we only need to specify name and order of the old positional parameters in the decorator.
>>> @legacy_api('d', 'c') ... def fn(a, b=None, *, c=2, d=1, e=3): ... return c, d, e
After adding the decorator, users can keep calling the old API and get a DeprecationWarning:
>>> fn(12, 13, 14) == (2, 14, 3) True
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
Built Distribution
File details
Details for the file legacy_api_wrap-1.4.tar.gz
.
File metadata
- Download URL: legacy_api_wrap-1.4.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92dfa274cedb26d6e6f70fac85c856fbdcc05058066656d76a665fb4bf11b785 |
|
MD5 | 6dc54274aa85013398db1302b7f95b7a |
|
BLAKE2b-256 | d5de35984e2270dce9f5895849668c34e4da646b4ac5293f679b23ede3d6d7f0 |
File details
Details for the file legacy_api_wrap-1.4-py3-none-any.whl
.
File metadata
- Download URL: legacy_api_wrap-1.4-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf81b8ee432d80e7203aa079c26fc3a0f228d158db808868f10c2e36a8f64dbd |
|
MD5 | 35e78778109214b5b0ab4f6f5b018a54 |
|
BLAKE2b-256 | 9708eaf39f00542e4181b65617805f116a0d38daec98d0dce36ec94327ca8fc4 |