Argumentize decorator allow convert any function into kind a 'pure' function that eliminate all globals and closures as a implicit dependencies but allow them to be passed as regular key-value arguments.
Here is a simple example:
from argumentize import argumentize
x = 100
def foo(a, b, c):
return a + b + c + x
foo = argumentize(foo)
foo(1, 2, 3) # 106
foo(1, 2, 3, x=10) # 16
Argumentized can be any dependency not only a variable. Here is how you can use it with a function:
from argumentize import argumentize
def foo(a, b, c):
return a + b + c
def bar(a, b, c, d):
return foo(a, b, c) + d
bar = argumentize(bar)
bar(1, 2, 3, 4) # 10
bar(1, 2, 3, 4, foo=lambda a, b, c: a * b * c) # 24
Argumentize can be used as a decorator:
from argumentize import argumentize
@argumentize
def foo(a, b, c):
return a + b + c
foo(1, 2, 3) # 6
foo(1, 2, 3, b=10) # 14
If you does not provide the value for argumented argument the default variable (either from globals or from the function closure) will be used
How to deploy
We use setup.py and setup.cfg to deploy the package to PyPI. To create a source distribution and upload it to PyPI, run the following commands:
python setup.py sdist
Install twine if you haven't already:
pip install twine
Then upload the package to PyPI:
twine upload dist/*
Metadata
Release files for argumentize 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| argumentize-1.0.4.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argumentize-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / argumentize-1.0.4.tar.gz
| Download URL | argumentize-1.0.4.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75d7e706b3024a0fa37fbfcf4bf891bec2cabdec865e0c33ba8fbff1a586354c
|
|
BLAKE2b-256 checksum How to use checksums |
3c92dab9502a23eb0b80aa88734cab6b7b656ef693bdb010c91e789dc630c23a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|
Release files / argumentize-1.0.4-py3-none-any.whl
| Download URL | argumentize-1.0.4-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53ef7a30c345cb34a66bf8d8fa6b291f568bddf17bd41e57509f8c1818f6e680
|
|
BLAKE2b-256 checksum How to use checksums |
8f526e6918f6e8514b50638830001846012317bc539128966d019e867badc89c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.0
|