Skip to content

Instantly share code, notes, and snippets.

@pskupinski
Created July 2, 2010 12:03
Show Gist options
  • Save pskupinski/461272 to your computer and use it in GitHub Desktop.
Save pskupinski/461272 to your computer and use it in GitHub Desktop.
import javax.script._
import org.python.core._
import org.python.util._
import java.util.List
def pythonInterpreterTest {
val interp = new PythonInterpreter
interp.exec("commandList = [\"meh\"]")
val pyObj = interp.get("commandList")
val jObj = pyObj.__tojava__(classOf[Object])
// In the above using classOf[List[Object]] in __tojava__ I got an Object
// rather than a List[Object]. I'm not sure how that occurred.
val jList = jObj.asInstanceOf[List[Object]]
println(jList.size)
}
def jsr223PythonInterpreterTest {
val interp = new ScriptEngineManager().getEngineByName("python")
interp.eval("commandList = [\"meh\"]")
val obj = interp.get("commandList")
val jList = obj.asInstanceOf[List[Object]]
println(jList.size)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment