I'm converting some Java examples to Python and I've seen direct function callers in these examples. Well, there's no problem, because I'm using lambda
when it is one line (It's totally fine). However, I would like to discover if a form exists to express without creating a function like def
keyword or call into a string as exec()
.
Example:
genericObject.onTrue(
callWithRunnable(
() -> { // If this were one line, I could use a lambda here (Python's Callable)
function1();
function2();
},
)
);