IoPython, raw but cool

I nosed around in Io’s “addons” folder, which you also can pull from the Git repository, see the Io homepage.

Update: of course, this was reported when it was fresh, with nice examples, too: pinupgeek’s blog is full of Io goodness. (Thanks, trevor!)

While nosing, I met the Python module, which lets you run Python functions in Io. It was written last year, the copyright statement shows:

  docCopyright("Aslak Gronflaten", 2006)

IoPython lacks tests, real documentation, and such, and it does not do memory management:

* Convert an Io object to PyObject.
* At the moment, we can't pass in any objects, just those that can be translated,
* until I build a python wrapper around an io object, reverse of what I did here.
* TODO: Memory management!!!

Does not seem impossible.

But I get a nice vibe from these lines:


  # 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
  

Io could improve its library situation, if IoPython were less raw. Things will improve with time. In the meantime, I’m gonna learn more Io.

Published by olleolleolle

Olle is a programmer, enjoying sunny Malmö in Sweden.

Join the Conversation

2 Comments

  1. I’m interested in seeing this get polished up. Do you think the purpose is to create hybrid Io/Python programs, or simply call up existing Python scripts for re-usability? Jython comes to mind.

  2. Polished, and documented, and exampled: Oh, man, it’d be cool.

    I guess “Use Io to script your config file in my Python program” would be one kind of hybrid.

    Using specialized Py modules in one’s Io program would extend one’s immediate “reach” quite a bit. The world is awash in Python stuff, not so much in Io.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.