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
#####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.0.1.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for shorten_func-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e89626cc3eb2b8d8357b21f3e4c45d59932d08995f165fee0a7abea73c16a947 |
|
MD5 | ed6a89a148153a87ebba805a1064fddb |
|
BLAKE2b-256 | 2fe155eeb08e0755d46fe932811de4320de3d62e120be079b4031c6449b0fbac |