Message5851
I am not sure if "commutative property is lost" is a right description here.
The exception is thrown because org.jython.core.PyArray has performed some check in __add__(). One of them is
final PyObject array___add__(PyObject other) {
PyArray otherArr = null;
if(!(other instanceof PyArray)) {
throw Py.TypeError("can only append another array to an array");
}
So from PyArray point of view, it cannot operate on your class MyJava21
I think it is a right behavior.
In C python, you cannot just add anything to a list. For example, "1 + [2, 3]" will throw an example.
The appearance of __add__ is commutative between your class and list probably arises because
1) no such check is enforced in jython 2.1, and
2) your code did not check if the operand can be added to MyJava21 |
|
Date |
User |
Action |
Args |
2010-06-28 21:06:22 | akong | set | messageid: <1277759182.19.0.99315760207.issue1622@psf.upfronthosting.co.za> |
2010-06-28 21:06:22 | akong | set | recipients:
+ akong, babelmania |
2010-06-28 21:06:22 | akong | link | issue1622 messages |
2010-06-28 21:06:21 | akong | create | |
|