jython

Alternatives to multimethods in Scala or Jython

I often face the problem of wanting to add additional methods to classes I don't control. For instance, I might want to have a function prettyPrint that can operate on different object types that do not have a unified api (e.g. special __str__ methods). The Nice language and R accomplishes this using multimethods, which avoid the Visit...

Listening EventBus in Jython

I'm trying to use EventBus from Jython. Sending events to the from Jython bus works as expected, they can be listened from my Java code. But subscribing to the bus from Jython is problematic. I'm trying this: class Listener(EventTopicSubscriber): def onEvent(self, topic, object): print("got an event") EventBus.subscribe("To...

Extending Jython Syntax

I would like to add syntax to Jython to enable a nicer API for users. For instance, matrix libraries like NumPy would benefit from having both matrix and elementwise operations like Matlab's :* vs. * infix operators. You can create a matrix in Octave using: A = [ 1, 1, 2; 3, 5, 8; 13, 21, 34 ] which is considerably nicer than NumPy's...

Jython zxJDBC.cursor fetchone() for a session variable ,I get an array

I use Jython2.5.0, mysql-connector-java-5.0.8-bin.jar, because my sever is Mysql5.0.38 There is a problem in my Jython application. Two functions: def act_query(query): connection = conn //conn is global and has been assigned when called cursor = connection.cursor() num_affected_rows = cursor.execute(query) curso...

class importing in jython

I've got a jython script that needs to include a class (from JUnit in this case). I've got the junit jar in "some/path/junit.jar". My script is: from junit.textui import TestRunner TestRunner.Main(["name of some class here"]) I'm running it like this: java -cp "some/path/junit.jar" -jar jython.jar script.py but it complains that: ...

transforming Jython's source / ast

I've got a problem to solve in Jython. The function I've got looks like this: ok = whatever1(x, ...) self.assertTrue("whatever1 failed: "+x...(), ok) ok = whatever2(x, ...) self.assertTrue("whatever2 failed: "+x...(), ok) [ many many lines ] ... There are many tests that look like this, they contain mostly ok=... tests, but there ar...

How do i make Pydev + jython to startup faster when running a script?

Hi, i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program. this is probably something due to libraries load time. What can i do to speed it up ? Thanks , yaniv ...

Can you run Jython on the JVM that runs on Pulse smart pens?

I'm looking at developing an application that takes advantage of the Pulse smart pen. I would rather do it in python than java. Its not clear what version of the jvm runs on the pen, as evidence here in the tech specs Are there limitations on whether or not jython and jruby will run on mobile version of the jvm? ...

How do you use Jython for your Java development?

So you aren't allowed to use Jython for the production code you develop at work. You can, instead, use it to help you on your daily tasks and activities writing that Java code. The question is: How do you use Jython and how did that help your development and/or productivity? ...

Should I keep my Python code at 2.x or migrate to 3.x if I plan to eventually use Jython?

I have a large infrastructure that is written in Python 2.6, and I recently took a stab at porting to 3.1 (was much smoother than I expected) despite the lack of backwards compatibility. I eventually want to integrate some of this Python code with a lot of Java based code that we have, and was thinking about giving Jython a try. However...

How to instantly termainate an un-supervised script on demand?

I have a GUI which resembles an interpreter. It allows the user to write a script in Jython (implementation of Python in Java) and run it whenever he wants. Apart from that, I also wish to allow the user to instantly terminate the run whenever he wants. Thing is, I don't really know how to do it. The script is being run on a different T...

Using/Creating Python objects with Jython

HI, lets say I have a Java interface B, something like this. B.java : public interface B { String FooBar(String s); } and I want to use it with a Python class D witch inherits B, like this. D.py : class D(B): def FooBar(s) return s + 'e' So now how do I get an instance of D in java? I'm sorry im asking such a n00b que...

Using Jython with M2Eclipse

I currntly use M2Eclipse for the majority of my Java development and Pydev for Python/Jython development within Eclipse. I would like to use Jython to prototype and test classes within my Java projects. The M2Eclipse plugin manages all the dependencies defined in the Maven pom.xml file automatically. Is there anyway for Pydev to utilis...

Why can I not import the Python module 'signal' using Jython, in Linux?

I can't find any reference to the 'signal' class being left out in Jython. Using Jython 2.1. Thanks ...

XStream-like XML serialization for Jython objects?

Jython is great for creating custom data structures on need basis, but how to store their instances? Apparently it's possible to do it via java.io.Serializable, but ObjectStreams are not human readable; I would prefer XML. I naïvely tried XStream to serialize a simple object created in Jython and translated to Java with PyObject's __toj...

Jython 2.5.1: "ImportError: No Module named os"

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 som...

Jython 2.5.1, Eclipse & os.path

I have imported the Jython2.5.1 standalone jar into my build path in Eclipse. Whenever I run any Jython code from within Eclipse, that uses the os.path module, the app barfs: 'Execution failed. Traceback (most recent call last): File "<string>", line 1, in <module> File "../lib/python/threading.py", line 6, in <module> import traceb...

BeautifulSoup with Jython

I just tried to run BeautifulSoup (3.1.0.1) with Jython (2.5.1) and I was amazed to see how much slower it was than CPython. Parsing a page (http://www.fixprotocol.org/specifications/fields/5000-5999) with CPython took just under a second (0.844 second to be exact). With Jython it took 564 seconds - almost 700 times as much. Can anyone ...

Set WAS Process Definition Environment Entries using Jython?

Is it possible to add custom Process Definition environment entry in a WebSphere Application Server using a jython script? I see that the existing properties in the server.xml are assigned auto-generated IDs, is it possible to retrieve those prop without knowing their ID? <environment xmi:id="Property_1248356598212" name="<my_prop>" v...

Why does Jython refuse to find my Java package?

I know it's something silly, but for some reason Jython refuses to find javax.swing. I'm using Java 1.6.0_11. This is my start-up script: @echo off "%JAVA_HOME%\bin\java" -Xmx1024M -classpath ".;c:\Projects\Jython2.5.1\jython.jar" org.python.util.jython My output looks like: Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)...