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.2.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for shorten_func-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5049916479ac03e00ed85c3ee764aadf8254ee31284cde12cb05a7261552d916 |
|
MD5 | d37ad8daea2275fb76de00dc16f81b65 |
|
BLAKE2b-256 | f17fba0b2233fcec504e21ba37026dc6671ab27b4deb95a54d0d6f74419cd9f1 |