JPython embed question

Ype Kingma ykingma at
Fri Dec 22 14:14:04 EST 2000


you wrote:
> In the JPython demo/embed example, we find how to create an instance of
> a class, e.g.:
>   interp.set("foo1", new Foo());
>   interp.set("bar1", new Bar());
> I'd like to be able to dynamically create an instance of a class - e.g.,
>   createInstance(String instName, String className)

You might subclass the class of interp in Java:

class MyInterpreter extends PyInterpreter /* or whatever it's called */ {
  /* constructors as needed */

  void createInstance(String instName, String className) {
    set(instName, newByClassName(className));
    /* sorry, forgot the actual name of newByClassName() from java.lang */
} /* class MyInterpreter */

Kind regards,

P.S. Riddle: what's my default Python indentation?

(email at

More information about the Python-list mailing list