Skip to main content

Reduce to pass the same parameters multiple times when calling a function multiple times

Project description


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


pip install shorten-func


def long_function(variable_passed_repeatedly, variable):
    return variable_passed_repeatedly + variable


value_1 = long_function(variable_passed_repeatedly, 'var_1'')
value_2 = long_function(variable_passed_repeatedly, 'var_2')


from shorten_func import shorten_func
get = shorten_func(long_function, variable_passed_repeatedly)
value_1 = get('var_1')
value_2 = get('var_2')


def set_child_full_name(family_name, child_first_name):
    return child_first_name + family_name


child_1 = set_child_full_name('family_name', 'Messi')
child_2 = set_child_full_name('family_name', 'Ronaldo')


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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for shorten-func, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size shorten_func-0.1.1-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size shorten-func-0.1.1.tar.gz (1.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page