Issue222795
Created on 2000-11-18.18:51:01 by bckfnn, last changed 2000-11-18.22:04:01 by bckfnn.
Messages | |||
---|---|---|---|
msg27 (view) | Author: Finn Bock (bckfnn) | Date: 2000-11-18.18:51:01 | |
Calling the constructor of a PyObject subclass with arguments will cause the __repr__() methods to be ignored. JimH hinted that this would be solved in jpython1.1 (see below). JPython 1.1beta1 on java1.2.1 Copyright ® 1997-1999 Corporation for National Research Initiatives >>> import test142j >>> a = test142j([1.1, 1.2, 1.3]) >>> print len(a) 3 >>> print repr(a) test142j@442a4904 >>> b = test142j.new([1.1, 1.2, 1.3, 1.4]) >>> print len(b) 4 >>> print repr(b) 1.1, 1.2, 1.3, 1.4, >>> -------------------- test142j.java -------------------- import org.python.core.*; public class test142j extends PyObject { double[] data; int len; public test142j(double[] darray) { data=darray; len=data.length; } public int __len__() { return len; } public PyString __repr__() { StringBuffer buf = new StringBuffer(); for(int i=0; i<len; i++) { buf.append(data[i]); buf.append(", "); } return new PyString(buf.toString()); } public static test142j new$(double[] array) { return new test142j(array); } } -------------------- END -------------------- On 19981208, JimH wrote: Your problem is that under the current JPython release, you can't directly call the constructors of classes that subclass from PyObject and get the expected result. This is considered a clear design mistake in JPython and will be fixed in 1.1. |
|||
msg28 (view) | Author: Finn Bock (bckfnn) | Date: 2000-11-18.22:04:01 | |
This is actually a duplicate of bug 122790. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2000-11-18 18:51:01 | bckfnn | create |
Supported by Python Software Foundation,
Powered by Roundup