[Edu-sig] looking for help with Jython...
Jeffrey Elkner
jeff@elkner.net
29 Apr 2003 23:35:34 -0400
I'm in the middle of learning some Java to get ready for next year's AP
CSC course. I would like to make good use of the Python my students
already know, and I was thinking that Jython might offer some
interesting educational opportunities.
What I would most like to be able to do is to import Java classes into
Python in order to be able to "play around" with them in the
interpreter. So far, I have not been able to make this work. I'm
starting with a simple example from our book:
class Vehicle {
public int passengers;
public int fuelcap;
public int mpg;
public Vehicle(int p, int f, int m) {
passengers = p;
fuelcap = f;
mpg = m;
}
public int range() {
return mpg * fuelcap;
}
public double fuelneeded(int miles) {
return (double) miles / mpg;
}
}
(Actually, I added all the "public"s because otherwise Jython couldn't
see them when I did:
import Vehicle
How can I create a Vehicle object inside of Jython?
Thanks!
--
Jeffrey Elkner <jeff@elkner.net>
Open Book Project <http://ibiblio.org/obp>