From: <Pet...@ua...> - 2002-09-24 16:00:26
|
Hello everybody, Yet another newby question ;-) I have several java objects that contain integer and float values. I also have several jython Integer/float values that are PyInteger or PyFloat types. The problem is, I cannot seem to be able to convert the Java int's/floats into PyIntegers or PyFloats, explicitly or implicitly. My dilemna is I need to perform math between PyIntegers and Java Integers and PyFloats and Java Floats. =3D20 Jython seems to lack a means to convert java numeric types to it's own, and coercion doesn't work either, that is... from java.lang import * a=3D3DInteger(10) result=3D3D1+int(a) <- This fails :-( I use lot of interaction between Jython native types and Java Native types, and this is really painful. Any help would be appreciated... =3D3D=3D3Dpete=3D3D=3D3D Best regards, =3D3D=3D3Dpete=3D3D=3D3D P. A. Rupp=3D20 United Airlines Corp. (WHQKT) voice: 847-700-3226 email: pet...@ua... =2D-openmail-part-4d708822-00000001-- |
From: Samuele P. <ped...@bl...> - 2002-09-24 16:38:21
|
Hi. yes, int fails with an Integer and that's a useful but for the moment missing feature. So at the moment what you can use is javaInt.intValue() OTOH I don't get why you need or how you get java Integer instances on the Python side. If a java method has return type Object or Integer, you will get a Python integer on the Python side. Same for a field. And you can pass a Python int to a function expecting a java Integer or java Object and that will converted automatically to a Java Integer. Only the constructor Integer called from Jython will give you an uncoverted java Integer. regards. |