dot operations
robert
no-spam at no-spam-no-spam.invalid
Thu Jan 11 05:41:33 EST 2007
jm.suresh at no.spam.gmail.com wrote:
> 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?
import numpy
You'll not even need dots
More information about the Python-list
mailing list