Message5851

Author akong
Recipients akong, babelmania
Date 2010-06-28.21:06:21
SpamBayes Score 0.033422023
Marked as misclassified No
Message-id <1277759182.19.0.99315760207.issue1622@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2010-06-28 21:06:22akongsetmessageid: <1277759182.19.0.99315760207.issue1622@psf.upfronthosting.co.za>
2010-06-28 21:06:22akongsetrecipients: + akong, babelmania
2010-06-28 21:06:22akonglinkissue1622 messages
2010-06-28 21:06:21akongcreate