Hello ROOTers,
I wrote a class which has a 2D array member and two operators accessing the contents of the array.
for example,
class Foo
{
private:
Double_t* fArray;
public:
Double_t& operator()(Int_t x, Int_t y){return fArray[x][y];}
const Double_t& operator()(Int_t x, Int_t y) const {return fArray[x]
[y];}
}
This class works fine in C++ codes. But if I call the operator () from Python,
>>> foo = Foo() # constructor is not written in the above example...
>>> a = foo(1, 2) # OK
>>> foo(1, 2) += 10. # NG
SyntaxError: can't assign to function call
Is there any way to make python assign to foo(1, 2)? Other setter/ getter methods will work if I add them. But I prefer simple script which is easy to read instead of using a setter.
I know that this is the same error when one call
>>> abs(10.) = 5.
and I understand that Python's behavior is correct.
Regards,
OKUMURA, Akira oxon_at_ceres.phys.s.u-tokyo.ac.jp
Department of Physics, The University of Tokyo
7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
TEL/FAX +81 3-5841-4173/4059
Skype : okumura.akira
Received on Fri Jun 27 2008 - 01:06:43 CEST
This archive was generated by hypermail 2.2.0 : Fri Jun 27 2008 - 05:50:08 CEST