In Python 3, can we store specific function parameters in variable?

Viewed 57

I have some functions that have exactly the same parameters. Is there a way to store these parameters to a variable and use it in each one to increase code readability?

Here is the current code:

def say_ok(language: Languages = Languages.ENGLISH) -> str: ...

def greet(language: Languages = Languages.ENGLISH) -> str: ...

def goodbye(language: Languages = Languages.ENGLISH) -> str: ...

def laugh(language: Languages = Languages.ENGLISH) -> str: ...

Note that Languages is an enumeration. I would like it to be like this:

LANGUAGE_PARAMETER = parameter(language: Languages = Languages.ENGLISH)

def say_ok(LANGUAGE_PARAMETER) -> str: ...

def greet(LANGUAGE_PARAMETER) -> str: ...

def goodbye(LANGUAGE_PARAMETER) -> str: ...

def laugh(LANGUAGE_PARAMETER) -> str: ...

Should I use something from typing or functools module? Thank you very much!

0 Answers
Related