Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python and Ruby interpreter

Tags:

python

ruby

I read in books that you are capable of incorporating scripts of other languages into Python. Is it possible to take variables from a ruby script, pass them to a python function, and then return the output back to Ruby? If so, how? Every answer will be greatly appreciated!

like image 750
Weremole79 Avatar asked Jul 03 '26 02:07

Weremole79


1 Answers

Here are a few ways you could do it. Note that none of these has exceptionally high performance:

  • It might be overkill, but I have used socket programming before to set up a client-server relationship between Python and Ruby. At the very least this approach feels cool.

  • You could write and read from a common file. But then you have to worry about concurrency issues.

  • backticks can be used to send something to a Python module. In the Python module you wouold then use argv to process the sent data and then return back some result to the Ruby code.

For further information I would suggest looking at another similar StackOverflow question.

like image 90
mjgpy3 Avatar answered Jul 04 '26 15:07

mjgpy3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!