From: Jeff E. <JEm...@lg...> - 2004-03-09 22:45:17
|
You can invoke toString on an array from jython like this: >>> import jarray,java >>> ca=jarray.zeros(4,'c') >>> java.lang.Object.toString(ca) '[C@5ec59c' It still doesn't return what Patrick wanted. He already had the best solution in his original post, which is to explicitly construct a java.lang.String from the char[]. -----Original Message----- From: Oti [mailto:oh...@ya...] Sent: Tuesday, March 09, 2004 3:21 PM To: Jeff Emanuel; Patrick Bielen; Jython Mailinglist Subject: RE: [Jython-users] Array to String ??? [ Jeff Emanuel ] > An array is an Object, regardless of your HO. From the > Java language specification: > > "In the Java programming language arrays are objects (?4.3.1), are > dynamically created, and may be assigned to variables of type Object > (?4.3.2). All methods of class Object may be invoked on an array." Sorry, i confused primitive types with arrays of primitive types. The problem probably is: >>> import jarray >>> ca = jarray.zeros(4, 'c') >>> pw = ca.toString() Traceback (innermost last): File "<console>", line 1, in ? AttributeError: instance of 'org.python.core.PyArray' has no attribute 'toString' >>> Best wishes, Oti. |