Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6849 > unrolled thread

Passing array from java to python

Started byloial <jldunn2000@gmail.com>
First post2011-06-02 02:54 -0700
Last post2011-06-03 11:54 -0700
Articles 6 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  Passing array from java to python loial <jldunn2000@gmail.com> - 2011-06-02 02:54 -0700
    Re: Passing array from java to python Chris Rebert <clp2@rebertia.com> - 2011-06-02 03:16 -0700
      Re: Passing array from java to python loial <jldunn2000@gmail.com> - 2011-06-02 03:47 -0700
        Re: Passing array from java to python Chris Rebert <clp2@rebertia.com> - 2011-06-02 04:07 -0700
        Re: Passing array from java to python Ian Kelly <ian.g.kelly@gmail.com> - 2011-06-02 11:06 -0600
    Re: Passing array from java to python Marco Nawijn <nawijn@gmail.com> - 2011-06-03 11:54 -0700

#6849 — Passing array from java to python

Fromloial <jldunn2000@gmail.com>
Date2011-06-02 02:54 -0700
SubjectPassing array from java to python
Message-ID<088cff0c-ea3e-4574-9ca0-3c9b1393c89c@v31g2000vbs.googlegroups.com>
I need to pass some sort of array or hashmap from Java and read the
data in a python script (which will be called by the java class). Is
there any neater way  to do this other than just passing strings?

[toc] | [next] | [standalone]


#6851

FromChris Rebert <clp2@rebertia.com>
Date2011-06-02 03:16 -0700
Message-ID<mailman.2385.1307009819.9059.python-list@python.org>
In reply to#6849
On Thu, Jun 2, 2011 at 2:54 AM, loial <jldunn2000@gmail.com> wrote:
> I need to pass some sort of array or hashmap from Java and read the
> data in a python script (which will be called by the java class). Is
> there any neater way  to do this other than just passing strings?

Jython?: http://www.jython.org/

Or depending on how you define "just passing strings", JSON:
http://json.org/
http://docs.python.org/library/json.html

Cheers,
Chris

[toc] | [prev] | [next] | [standalone]


#6853

Fromloial <jldunn2000@gmail.com>
Date2011-06-02 03:47 -0700
Message-ID<96a88912-152d-4e1a-a8c9-50775fc5a133@f9g2000vbz.googlegroups.com>
In reply to#6851
Unfortunately using jpython or json are not options at the moment

[toc] | [prev] | [next] | [standalone]


#6855

FromChris Rebert <clp2@rebertia.com>
Date2011-06-02 04:07 -0700
Message-ID<mailman.2388.1307012839.9059.python-list@python.org>
In reply to#6853
On Thu, Jun 2, 2011 at 3:47 AM, loial <jldunn2000@gmail.com> wrote:
> Unfortunately using jpython or json are not options at the moment

What rules out JSON that does not also rule out the "just passing
strings" approach?

What about (*shudder*) XML? (Can't believe I just said that...)

Cheers,
Chris

[toc] | [prev] | [next] | [standalone]


#6873

FromIan Kelly <ian.g.kelly@gmail.com>
Date2011-06-02 11:06 -0600
Message-ID<mailman.2393.1307034439.9059.python-list@python.org>
In reply to#6853
On Thu, Jun 2, 2011 at 4:47 AM, loial <jldunn2000@gmail.com> wrote:
> Unfortunately using jpython or json are not options at the moment

How about JPype?  Or do the Java and Python need to be in separate processes?

[toc] | [prev] | [next] | [standalone]


#6961

FromMarco Nawijn <nawijn@gmail.com>
Date2011-06-03 11:54 -0700
Message-ID<cf9ca311-7a12-441e-b05a-af74ca6af5e7@x1g2000yqb.googlegroups.com>
In reply to#6849
On Jun 2, 11:54 am, loial <jldunn2...@gmail.com> wrote:
> I need to pass some sort of array or hashmap from Java and read the
> data in a python script (which will be called by the java class). Is
> there any neater way  to do this other than just passing strings?

I recently had to deal with the same problem, some bi-directional
communication between Java and Python. Several options were discussed
between me and my fellow programmer. In the end we settled for XML-
rpc. It works remarkably well in our case. We use it to pass test and
simulation data to GUI code. XML-rpc is very well supported in python.
Basic types (lists, dicts etc.) are encoded automatically. If the
arrays are very large, I would probably use an intermediate database
(e.g. Hdf5) for storage and then use some sort of messaging to inform
the Java code of any changes.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web