jython question (interesting behavior)

pythonUser_07 zsolt-googleP6463 at mailblocks.com
Fri Mar 4 01:06:31 CET 2005


Is this the correct place to post a jython question?

I posted the following in the jython group, but I figured I'd post here
too:
_________________________________________
I am assuming that the PythonInterpreter environment is not a unique
environment from within a jvm.

Here is some pseudo code to show what I am talking about
1) create a jython module  file, lets call it "mytest"
   with a simple static class
   class simpleS:
      myVar = "test01"
2) Now set up two interpreter environments from within
   the same jvm
   PythonInterpreter py = new PythonInterpreter()
   PythonInterpreter py1 = new PythonInterpreter()
3) now in both interpreters, import the module
   py.exec("import mytest")
   py1.exec("import mytest")
   Now for both interpreters run
   "print mytest.simpleS.myVar"
4) Now for the crazy part.
   in the py interpreter run
   "mytest.simpleS.myVar = 'test02'
   in py1 look at the value
   "print mytest.simpleS.myVar"

Very interesting behavior.  So it seems that each python interpreter
instance does not act as its own seperate space.

Maybe I just have not gotten there yet with the docs.  I did notice
something about the initialize() function associated with the
interpreter which is only supposed to be run once.




More information about the Python-list mailing list