Python element-wise tuple operations like sum -


There is no way to get topple operation in Python to work this way:

  & gt; & Gt; & Gt; A = (1,2,3)> & Gt; & Gt; B = (3,2,1)> & gt; & Gt; & Gt; Instead of A + B (4,4,4)  

:

  & gt; & Gt; & Gt; A = (1,2,3)> & Gt; & Gt; B = (3,2,1)> & gt; & Gt; & Gt; A + B (1,2,3,3,2,1)  

I know that it works like this because __ add __ and __ mul __ If the methods are defined to function like this, will it be the only way to redefine them?

  import operator tupl (map operator (a, a, b))  

Comments