8

I am interested in getting some Python code talking to some Ruby code on Windows, Linux and possibly other platforms. Specificlly I would like to access classes in Ruby from Python and call their methods, access their data, create new instances and so on.

An obvious way to do this is via something like XML-RPC or maybe CORBA but I would be interested in any other approaches.

What have other people done to get code from Python and Ruby communicating with one another, either locally on the same system or remotely accross a network?

Thanks in advance.

QAZ
  • 4,870
  • 6
  • 36
  • 50

5 Answers5

4

Well, you could try named pipes or something similar but I really think that XML-RPC would be the most headache-free way.

Toni Ruža
  • 7,462
  • 2
  • 28
  • 31
3

Please be advised that I don't speak from personal experience here, but I imagine JRuby and Jython (The ruby and python implementations in the JVM) would be able to to easily talk to each other, as well as Java code. You may want to look into that.

James McMahon
  • 48,506
  • 64
  • 207
  • 283
  • This sounds interesting, does anyone have experience with this? – monkut Oct 16 '08 at 08:52
  • Yes, i like the idea of everything opperating in the same jvm and as such a 'native' bridge between them. interesting suggestion nemo, thanks. – QAZ Oct 16 '08 at 10:19
2

This isn't what your after, but worth a read: embed Python interpreter in Ruby: this code's pretty old

http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python/doc/index.html

OR: why, rewriting bytecodes

http://github.com/why/unholy/tree/master

Gene T
  • 5,156
  • 1
  • 24
  • 24
1

Using JRuby/Jython for Ruby/Python interoperability? has more information. Of note: JRuby and Jython don't have object compatibility, but IronPython and IronRuby do.

Community
  • 1
  • 1
Hans
  • 2,230
  • 23
  • 23
1

Expose your Ruby classes as web services using Sinatra, Rails, or, plain old Rack.

Expose your Python classes as web services using web.py, flask, Django, or App Engine.

Use HTTParty for Ruby to build an API into your Python classes.

Use a Python REST library to build an API into your Ruby classes.

user94154
  • 16,176
  • 20
  • 77
  • 116