Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emanuelhfarias/f5506d7da9da528fc825fa26dec93c01 to your computer and use it in GitHub Desktop.
Save emanuelhfarias/f5506d7da9da528fc825fa26dec93c01 to your computer and use it in GitHub Desktop.
# ----> Ruby File: hi.rb
# Importing code from Python to Ruby
p obj = eval(`python hi.py`.chomp)
# Exporting code from Ruby to Python
p my_array = [[1,2,3],["hi", 1.5]]
# Executing Python code 'inside' Ruby passing args from ruby variables to python
p obj = eval(`python hi.py '#{my_array}'`.chomp)
# ---> Python file: hi.py
# Exporting code from Python to Ruby
my_array = [[1,2,3],["hi", 1.5]]
print(my_array)
# Importing code from Ruby to Python
import subprocess
obj = eval(subprocess.check_output("ruby hi.rb", shell=True).rstrip('\n'))
print(type(obj))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment