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
functools.reduce can be used to apply a function of two arguments to an iterable cumulatively, which would work for your example case
import operator as op
from functools import reduce
print(reduce(op.eq, map(str.upper, ['a', 'A'])))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With