J
jm.suresh
Hi,
Frequently I get to do like this:
a = (1, 2, 3, 4) # some dummy values
b = (4, 3, 2, 1)
import operator
c = map(operator.add, a, b)
I am finding the last line not very readable especially when I combine
couple of such operations into one line. Is it possible to overload
operators, so that, I can use .+ for element wise addition, as,
c = a .+ b
which is much more readable.
Similarly, I want to use .- , .*, ./ . Is it possible to do?
thanks.
-
Suresh
Frequently I get to do like this:
a = (1, 2, 3, 4) # some dummy values
b = (4, 3, 2, 1)
import operator
c = map(operator.add, a, b)
I am finding the last line not very readable especially when I combine
couple of such operations into one line. Is it possible to overload
operators, so that, I can use .+ for element wise addition, as,
c = a .+ b
which is much more readable.
Similarly, I want to use .- , .*, ./ . Is it possible to do?
thanks.
-
Suresh