I love both python and java and I’d love to have console in my game powered by python (jython). Handling input-output from PythonInterpreter is amazingly easy.
But right now, I need to access instance of my java application from jython. Can anyone point me to some article?
I need access to already existing instances created by java, not just classes (and creating instances in jython) as articles I found described.
From the Jython docs:
If you already have Jython setup, it should be as trivial as shown in the documentation to access Java Instances as they are treated as Python objects in the Jython environment.
Here’s a use case in embeding Python and Java into a single jar:
and finally, from Python’s tutorial:
Also make sure you understand what ‘already existing instances’ means vs classes. Any class you’re interacting with, already exists. If you meant creating new Java objects from within Jython, that shouldn’t be a problem as there is almost no interfacing code required from Python’s point of view (though a bit more from Java’s to create Python objects).
Good luck with your game console and hopefully the links will fill in the blanks you had about using Jython.