In nodeJS using lambda expressions you can create very clean callback code but defining and returning a function at the same time. Like so:
events.on("loaded", ()=>{
let x=1;
console.log("loaded!", x+2);
});
If I were to try to accomplish the same thing in python, I would need to define the function before using it in the callback:
def l():
x=1
print("loaded!", x+2)
events.on("loaded", l)
By my eye is is a lot harder to read.
My question is: is there a clean way of writing a multi-line function in python for callbacks that can be used in-line?
Note: I cannot use a lambda expressions as I need multi-line functions.
Please alert me if there is already an answer to this question that I wasn't able to find. I will happly remove this myself if that is the case.