Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby to Python bridge

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.

like image 792
QAZ Avatar asked Oct 15 '08 22:10

QAZ


People also ask

Can you use Ruby and Python together?

Ruby and Python are two highly sought-after programming languages. They share many similarities and both are powerful options that solve specific problems. But few people know that Ruby and Python can be brought together to create efficient apps with capabilities for heavy calculations and handling Big Data.

How do I run a Python script in rails?

To do so, you would need to make your script into a proper Python module, start the bridge when the Rails app starts, then use RubyPython. import to get a reference to your module into your Ruby code. The examples on the gem's GitHub page are quite simple, and should be sufficient for your purpose.


2 Answers

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

like image 117
Toni Ruža Avatar answered Oct 01 '22 10:10

Toni Ruža


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.

like image 27
James McMahon Avatar answered Oct 01 '22 09:10

James McMahon