This post originated from an RSS feed registered with Ruby Buzz
by rodney ramdas.
Original Post: Introducing IoPython: the Io-Python Bridge
Feed Title: pinupgeek.com
Feed URL: http://feeds.feedburner.com/pinupgeek
Feed Description: A personal take on Ruby and Rails
Aslak Gronflaten has created an Io-Python bridge i.e you can run Python modules from Io:
# Import a module
sys := Python import("sys")
"Which version of python are we running?" println
sys version println
"System path is returned as a list" println
sys path foreach(p, p println)
"Load the string module" println
string := Python import("string")
"Split a string" println
str := "Brave brave Sir Robin"
str println
string split(str) println
"Load a C module (.so)" println
t := Python import("time")
writeln("Current time is: ", t time)
"Another way to invoke a method" println
str = "UPPERlower"
write(str, " --> ")
string invoke("swapcase", str) println
This opens up a whole new world of possibilities. I mean you have every Python module at your disposable from Io. Sometimes you’ll need to tweaks thing a bit since there some things to iron out (like subclassing from Python) but it is quite usable.
Unpack it in your bindings directory where you previously unpacked or pulled the Io source and then a simple:
make
will make this go oempf.
Ofcourse you’ll need a recent version of Python installed.
I’ve tested it under osx and it works like a charm. We need much more tests like under linux so please let us know how your fare on irc (#io) or via the Io mailing list. Or comment here of course.
Thanks Aslak ! This is fantastic work.
(ps Aslak wrote this in like 3 days, shows the power of Io :-) )