Yeah, I've had to deal with that myself with IFCX Wings.
The problem is that with Python/Jython statements do not have values. That means a script engine has to decide whether to evaluate statements or expressions, and if you just evaluate expressions there is very limited Python stuff you can do.
Sticking with statements brings another problem which is that the JSR-223 Jython engine from scripting.dev.java.net
doesn't implement stdio properly. There is a fixed version in IFCX SVN --- ah, wait, just checked and I see my fix has made it there!
The IFCX JSR-223 engines may still be of interest to those who want binaries that are built for JDK 1.5 and therefore work fine for both Java 5 and Java 6 users.
You'll also find Scala, OCaml, and Adenine there.
As for making Jython more embedded scripting friendly, that will entail doing some parsing tricks to decide whether you have an expression or some statements. A plausible approach would be to examine the last line of the script and if it is an expression rather than a statement then code to make an assignment to a binding would be prepended. You'll notice the Jython embedding examples use that style of code.
There is an expression evaluator in Jython, and you can call it instead of using JSR-223 (I also made a JSR-223 Jython engine that used it for testing but have not kept it around) for simple expressions.
Eric Berry wrote: