jython

Jython 2.5.1: “ImportError: No Module named os”

随声附和 提交于 2020-02-01 19:59:06
问题 I looked through the other posts and bug reports and couldn't figure out what's causing this. I'm using Jython 2.5.1, in a Java project in Eclipse (Ubuntu 8.10). It has been added to the project as a standalone .jar file (I just replaced the old Jython 2.1 jar with this one). I'm running a script that uses the threading.py class. At some point the statement "import os" is evaluated from linecache.py and I get this error, which I can't seem to figure out how to fix: 'Execution failed.

Calling Python from Java through scripting engine (jython)?

僤鯓⒐⒋嵵緔 提交于 2020-01-28 18:26:46
问题 I'm trying to call Jython from a Java 6 application using javax.script : import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine pyEngine = mgr.getEngineByName("python"); try { pyEngine.eval("print \"Python - Hello, world!\""); } catch (Exception ex) { ex.printStackTrace(); } } } This

Calling Python from Java through scripting engine (jython)?

℡╲_俬逩灬. 提交于 2020-01-28 18:26:08
问题 I'm trying to call Jython from a Java 6 application using javax.script : import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine pyEngine = mgr.getEngineByName("python"); try { pyEngine.eval("print \"Python - Hello, world!\""); } catch (Exception ex) { ex.printStackTrace(); } } } This

Repeating a function a set amount of times in python

我只是一个虾纸丫 提交于 2020-01-26 04:31:20
问题 I am doing an intro class and they are asking me to repeat a function a certain amount of times, as I said this is an intro so most of the code is written so assume the functions have been defined. I have to repeat the tryConfiguration(floorplan,numLights) the amount of time numTries requests. any help would be awesome :D thank you. def runProgram(): #Allow the user to open a floorplan picture (Assume the user will select a valid PNG floodplan) myPlan = pickAFile() floorplan = makePicture

Programming Android apps in jython

好久不见. 提交于 2020-01-20 13:02:15
问题 The other day I came across a Python implementation called Jython. With Jython you can write Java applications with Python and compile them to pure Java. I was wondering: Android programming is done with Java. So, is it possible to make Android apps with Jython? 回答1: Jython doesn't compile to "pure java", it compiles to java bytecode - ie, to *.class files. To develop for Android, one further compiles java bytecode to Dalvik bytecode. This means that, yes, Jython can let you use Python for

Programming Android apps in jython

牧云@^-^@ 提交于 2020-01-20 12:53:48
问题 The other day I came across a Python implementation called Jython. With Jython you can write Java applications with Python and compile them to pure Java. I was wondering: Android programming is done with Java. So, is it possible to make Android apps with Jython? 回答1: Jython doesn't compile to "pure java", it compiles to java bytecode - ie, to *.class files. To develop for Android, one further compiles java bytecode to Dalvik bytecode. This means that, yes, Jython can let you use Python for

Error 1121 importing external library in Pig UDF in Jython

六月ゝ 毕业季﹏ 提交于 2020-01-15 19:17:03
问题 I'm having a problem using the python library simplejson in jython to write a Pig UDF. I need because jython-standalone-2.5.2.jar doesn't come with a JSON library. I'm using Apache Pig version 0.11.0-cdh4.4.0 (rexported) compiled Sep 03 2013, 20:25:46, and according to the documentation http://pig.apache.org/docs/r0.11.1/udf.html#python-advanced "You can import Python modules in your Python script. Pig resolves Python dependencies recursively, which means Pig will automatically ship all

Error 1121 importing external library in Pig UDF in Jython

ⅰ亾dé卋堺 提交于 2020-01-15 19:16:51
问题 I'm having a problem using the python library simplejson in jython to write a Pig UDF. I need because jython-standalone-2.5.2.jar doesn't come with a JSON library. I'm using Apache Pig version 0.11.0-cdh4.4.0 (rexported) compiled Sep 03 2013, 20:25:46, and according to the documentation http://pig.apache.org/docs/r0.11.1/udf.html#python-advanced "You can import Python modules in your Python script. Pig resolves Python dependencies recursively, which means Pig will automatically ship all

Binding container managed authentication alias with DataSource using jython script

你。 提交于 2020-01-15 11:30:08
问题 I'm using WebSphere 8.5 I've found out how to create JAASAuthData with username and password using jython script: objServerAttrs = AdminControl.completeObjectName('WebSphere:type=Server,*') cellName = AdminControl.getAttribute(objServerAttrs, 'cellName') sec = AdminConfig.getid('/Cell:%s/Security:/' % cellName) jaasAttr = [['alias', jaasAlias],['userId', jaasUser],['password', jaasPass]] jaasAuthData = AdminConfig.create('JAASAuthData', sec, jaasAttr) and how to create dataSource: dsAttrs = [

Appending values to a key if key already exists (python/jython)

╄→гoц情女王★ 提交于 2020-01-13 05:45:08
问题 I have a list that I need to make into a dictionary. The list has duplicate (soon to be) keys which have different values. How do I find these keys and append the new values to it? list=[q:1,w:2,q:7] dictionary= q:1,7 w:2 Thanks in advance 回答1: Make the values in your dictionary lists, so that you have: dictionary = {'q': [1, 7], 'w': [2] } etc. ie, your one-item values are one-item lists. This means when you have another 'q' , you can do this: dictionary['q'].append(5) Except that dictionary