Message21

Author bckfnn
Recipients
Date 2000-11-18.18:48:11
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Properly not a real bug, but JimH expressed his hope, that this would
be possible in JPython-1.1, even without the extra stripping of the
wrapper.

------------------ FILE: test127.py ------------------
import org, sys

s = """
def foo():
        print "foo bar zot"
"""

mod = org.python.core.PyModule("test127m", {})
#mod = org.python.core.PyInstance.__tojava__(mod,
org.python.core.PyModule)
                
code = compile(s, "test127m.py", "exec" )
exec s in mod.__dict__, mod.__dict__

sys.modules["test127m"] = mod
import test127m

test127m.foo()

------------------ END ------------------


Jim Hugunin wrote:

The following code will give you a brand new empty module called
"test".

>>> from org.python.core import PyModule, PyInstance
>>> test = PyModule("test", {})
>>> test = PyInstance.__tojava__(test, PyModule)

The cryptic last line is removing a wrapper layer from the PyModule
object -- this turns it from a generic Java object being proxied into
the Python world into a real PyModule object (which subclasses
directly from PyObject).  This is the sort of thing that I hope will
go away in JPython-1.1.
History
Date User Action Args
2008-02-20 17:16:37adminlinkissue222792 messages
2008-02-20 17:16:37admincreate