jython

Robocode + Python

半城伤御伤魂 提交于 2019-12-10 09:45:57
问题 The question is, how do you make a robot for Robocode using Python? There seem to be two options: Robocode + Jython Robocode for .NET + Iron Python There's some info for the first, but it doesn't look very robust, and none for the latter. Step by step, anyone? 回答1: As long as your java-class extends robocode.Robot everything is recognized as robot. It doesn't matter where you put the class. 来源: https://stackoverflow.com/questions/8683501/robocode-python

Developing Eclipse plugins without Java

百般思念 提交于 2019-12-10 05:38:31
问题 Is it possible to create Eclipse plugins/program Eclipse RCP apps without Java? (preferably in Jython) 回答1: This will be possible in the next Eclipse major release e4: One of the goals of e4 is to provide support for writing plugins in other languages. The quote is from http://wiki.eclipse.org/E4/JavaScript which summarizes the current state of using javascript to implement eclipse plug-ins in e4. This issue in eclipse's bugzilla issue #227058 also has some discussion on that, but I believe

Is there a way to create Eclipse plugins with Python?

不问归期 提交于 2019-12-10 04:24:56
问题 As far as I understand Eclipse doesn't provide user with python bindings by default. Nor any projects of such kind was I able to find with google. Are there any third-party plugins for that? Any tutorial? May be with Jython?.. 回答1: As far as I know, you need to use Java. Eclipse is written in Java, and even the vanilla application is made up of several Java components glued together by the core plugin loader. Jython might work if: you can cross-compile Python to Java bytecode (indeed you can,

How do I use unittest.TestResult?

痞子三分冷 提交于 2019-12-10 04:06:48
问题 I've only been using unittest for a short time. I am using Jython 2.7.10 "final release" In the Python 2.7 docs explaining TestResult it says: The following methods of the TestResult class are used to maintain the internal data structures, and may be extended in subclasses to support additional reporting requirements. This is particularly useful in building tools which support interactive reporting while tests are being run. startTest(test) ... stopTest(test) ... startTestRun() ...

Python Interpreter Jython - execution of modules

醉酒当歌 提交于 2019-12-09 05:46:27
Here's the link to the problem: Python Interpreter in Jython The following was a potential solution: interp.exec("import os.path.abspath(__file__)/printTwice.py)"); interp.exec("printTwice.print_twice('Adam')"); However it returned an error: This returned the following error: Exception in thread "main" SyntaxError: ("mismatched input '(' expecting NEWLINE", ('', 1, 22, 'import os.path.abspath(file)/printTwice.py)\n')) interp.exec("import printTwice"); interp.exec("printTwice.print_twice('Adam')"); This should work. 来源: https://stackoverflow.com/questions/31756461/python-interpreter-jython

How to read the last MB of a very large text file

我只是一个虾纸丫 提交于 2019-12-09 02:49:09
问题 I am trying to find a string near the end of a text file. The problem is that the text file can vary greatly in size. From 3MB to 4GB. But everytime I try to run a script to find this string in a text file that is around 3GB, my computer runs out of memory. SO I was wondering if there was anyway for python to find the size of the file and then read the last megabyte of it. The code I am currently using is as follows, but like I said earlier, I do not seem to have a big enough memory to read

Why is my file getting closed if I don't do anything with it for a while?

帅比萌擦擦* 提交于 2019-12-08 23:20:37
问题 Original situation: The application I'm working on at the moment will receive notification from another application when a particular file has had data added and is ready to be read. At the moment I have something like this: class Foo(object): def __init__(self): self.myFile = open("data.txt", "r") self.myFile.seek(0, 2) #seeks to the end of the file self.mainWindow = JFrame("Foo", defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (640, 480)) self.btn = JButton("Check the file",

How can I add jars dynamically to jython, inside script?

笑着哭i 提交于 2019-12-08 22:53:49
问题 I am writing a package in python that talks to an ldap server. I want it to work in CPython and Jython. To get it to work with CPython, I have successfully coded against python-ldap. However, to get it working with Jython, I must use a java jar. How can I distribute the jar file with my package, so that if it can "import java", it knows its jython, and dynamically adds the java jar to the path, and utilizies it. However, if that fails, it knows its CPython and uses the python-ldap libraries.

how to add module of python into java using jython jar

无人久伴 提交于 2019-12-08 17:39:30
I used Netbeans platform to build my application uasing java languge.I need to invoke some python functions into java class using jython was the only way. unfortunatly when I tried to run the program an error showed indicate that the application did not find the following modules Exception in thread "main" Traceback (most recent call last): File "script.py", line 13, in <module> import re ImportError: No module named re File "script.py", line 14, in <module> from string import * ImportError: No module named string Java Result: 1 this is the code in script.py that I want to invoke one of it's

Event handling with Jython & Swing

我的未来我决定 提交于 2019-12-08 17:06:06
问题 I'm making a GUI by using Swing from Jython. Event handling seems to be particularly elegant from Jython, just set JButton("Push me", actionPerformed = nameOfFunctionToCall) However, trying same thing inside a class gets difficult. Naively trying JButton("Push me", actionPerformed = nameOfMethodToCall) or JButton("Push me", actionPerformed = nameOfMethodToCall(self)) from a GUI-construction method of the class doesn't work, because the first argument of a method to be called should be self ,