If I want to keep things functional, and do not want to use *
in the middle, then what is the equivalent substitute function?
for example,
import operator as op
print(op.eq(*map(str.upper, ['a', 'A'])))
how do I avoid using *
here?
I created a function, like,
def unpack(args):
return *args
but it gives syntax error, print(*args)
works but return
fails
One way to achieve this is by creating a function named apply
.
def apply(func, args):
return func(*args)
apply(op.eq, map(str.upper, ['a', 'A']))