Created
February 12, 2016 23:47
-
-
Save eam/e678696bccf106861c8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| booger:python_in_ruby evan$ irb | |
| jruby-1.7.19 :001 > require 'ffi' | |
| => false | |
| jruby-1.7.19 :002 > module Python | |
| jruby-1.7.19 :003?> extend FFI::Library | |
| jruby-1.7.19 :004?> ffi_lib 'python' | |
| jruby-1.7.19 :005?> attach_function 'Py_Initialize', [], :void | |
| jruby-1.7.19 :006?> attach_function 'PyRun_SimpleString', [:string], :int | |
| jruby-1.7.19 :007?> end | |
| => #<#<Class:0x56aac163> address=0x122202b70 size=0> | |
| jruby-1.7.19 :008 > Python.Py_Initialize | |
| => nil | |
| jruby-1.7.19 :009 > Python.PyRun_SimpleString "print 1 + 1" | |
| 2 | |
| => 0 | |
| jruby-1.7.19 :010 > Python.PyRun_SimpleString "print map(lambda x: x*x, range(10))" | |
| [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] | |
| => 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment