I am using a Python library (APScheduler) that requires some function handlers. All these handlers functions are almost the same. The only difference is a "constant" (as in, logic is the same; only the constant used to reference some data structures is different).
I would like to have a single generic function for all the handlers such that I can minimise my code or not having to add new functions when I add new types. Moreover, this enables me to have my types declared in a configuration file.
In Javascript this would be possible like this:
function staticFunction(args) {
// ... this function I have to parameterise
};
function factory(type) {
return function(args) {
// ... this function is parametrised with "type"
};
}
addHandler(staticFunction)
addHandler(factory("apples"));
addHandler(factory("oranges"));
How do I do the same in Python?