Skip to main content

Simple library for patching function inner scope

Project description

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/*

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

argumentize-1.0.4.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

argumentize-1.0.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file argumentize-1.0.4.tar.gz.

File metadata

  • Download URL: argumentize-1.0.4.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for argumentize-1.0.4.tar.gz
Algorithm Hash digest
SHA256 75d7e706b3024a0fa37fbfcf4bf891bec2cabdec865e0c33ba8fbff1a586354c
MD5 fa42f257730ff29cf43e552ff8ecbb0d
BLAKE2b-256 3c92dab9502a23eb0b80aa88734cab6b7b656ef693bdb010c91e789dc630c23a

See more details on using hashes here.

File details

Details for the file argumentize-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: argumentize-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for argumentize-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 53ef7a30c345cb34a66bf8d8fa6b291f568bddf17bd41e57509f8c1818f6e680
MD5 3cd525b37f15d636f6dca8824b7224ea
BLAKE2b-256 8f526e6918f6e8514b50638830001846012317bc539128966d019e867badc89c

See more details on using hashes here.

Supported by

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