June 2002
Beginner to intermediate
640 pages
14h 24m
English
All instances of Java classes are of type Instance (org.python.core.PyInstance). Here I use a constructor to create a date. In Java, as in Python, a constructor is a method in a class, so this example demonstrates a method returning an instance of class Date.
>>> from java.util import Date >>> date = Date() >>> type(date) <jclass org.python.core.PyInstance at -1204237921>
Constructors don't behave like regular Java methods in Jython, however. Instead, they convert PyInstances of the class even if the class is a Java primitive wrapper. (Remember, methods that return primitive wrappers are converted to the corresponding Python types.) In this context, the Integer and Float constructors return PyInstances.
Import the Java primitive ...
Read now
Unlock full access