dot operations

jm.suresh@no.spam.gmail.com jm.suresh at gmail.com
Thu Jan 11 05:26:40 EST 2007


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




More information about the Python-list mailing list