Posts Tagged: Python

Adventures in Embedding Python on OS X – Part 1.5

So why part 1.5?  Cause I’m not really starting at the beginning.    I’ll write more later, but here is one way of embedding Python in an Objective-C application, getting access to the app’s objects from Python, and one way to pass ivars over to Python, using a Singleton to manage a pool of objects.

The example is not complete, and not without it’s problems in terms of design, and so on.  There are other ways to do this as well, for example using notifications, or perhaps bindings.   So your mileage may vary, but I hope it helps some people who have been asking about this lately. I have several other Python/ObjC embedding samples that I can share as well, and will endeavor to do so when I have time.

Here’s the source code (Xcode project, OS X 10.5.x, links to system python):

Snakes and Cats. Tab-completion in Python and iPython on Leopard

[UPDATE]: The latest builds of iPython have a fix for tab-completion built-in, so the patch mentioned below isn’t necessary.

Python users who are running Mac OS X 10.5, aka Leopard, will be pleased to find that Leopard ships with Python version 2.5.1, and comes with a host of wonderful things.  Especially in the PyObjC realm, something I’ll cover in another post.   Tiger had a rather lame build of Python 2.3 installed by default which had no readline support.