Reduce to pass the same parameters multiple times when calling a function multiple times
Project description
shorten-func
Reduce to pass the same parameters multiple times when calling a function multiple times
def shorten_func(func_name, *args_global, **kwargs_global)
:param func_name: the function name
:param args_global: arguments passed repeatedly
:param kwargs_global: keyword arguments passed repeatedly
:return: The same function but it requires fewer parameters
#####Installation: https://pypi.org/project/shorten-func/
pip install shorten-func
#####Usage:
def long_function(variable_passed_repeatedly, variable):
return variable_passed_repeatedly + variable
before:
value_1 = long_function(variable_passed_repeatedly, 'var_1'')
value_2 = long_function(variable_passed_repeatedly, 'var_2')
after:
from shorten_func import shorten_func
get = shorten_func(long_function, variable_passed_repeatedly)
value_1 = get('var_1')
value_2 = get('var_2')
#####Example:
def set_child_full_name(family_name, child_first_name):
return child_first_name + family_name
before:
child_1 = set_child_full_name('family_name', 'Messi')
child_2 = set_child_full_name('family_name', 'Ronaldo')
after:
from shorten_func import shorten_func
get = shorten_func(set_child_full_name, 'family_name')
child_1 = get('Messi')
child_2 = get('Ronaldo')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
shorten-func-0.1.1.tar.gz
(1.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shorten-func-0.1.1.tar.gz.
File metadata
- Download URL: shorten-func-0.1.1.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5696ccb3684b1489c426a82ab308fb21ecb4258b559f02b60e02e4f80cdc48c
|
|
| MD5 |
64dc570fd0b435460656e29ab7953e2c
|
|
| BLAKE2b-256 |
16193f8426fdc9d8ff56844336906caa9e6d15898677fc968fd83370fe735743
|
File details
Details for the file shorten_func-0.1.1-py3-none-any.whl.
File metadata
- Download URL: shorten_func-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aff58eb1c5c41f3fdac87c23cd967d65fc37fa89f04efee8c5682432a99f12a5
|
|
| MD5 |
0e454c4e4fd439d6feb017d591a45bae
|
|
| BLAKE2b-256 |
f8f80b72c5ccccbc043a40c85a035e63ec896fe5fb4a2f4001267845514000af
|