We often see that in a function call, another function call is nested, such as func1(some_arguments, func2(func3(value), some_another_arguments))
. Even with indentation and highlighting help, such code is still a little hard to read, because we need to start reading from the innermost parentheses and work our way out, unlike the usual left-to-right reading.
I have got an idea for ->
, with which we can use a prefix shorthand for a args. So like this:
expression -> callable(pass)
expression -> callable
callable(expression)
# the 3 above is equivalent
expression -> callable(1, pass, 3, kwarg1=4)
callable(1, expression, 3, kwarg1=4)
# the 2 above is equivalent
It basically puts the left expression to the position of the right pass
, but the expression is evaluated before anything on the right of the arrow. expression -> callable
is a grammar sugar for expression -> callable(pass)
With arrow calls we can do something -> print
or something -> logger.info