ANN: PyObjC 0.8

Bill Bumgarner
Mon, 23 Dec 2002 11:58:49 -0500

PyObjC version 0.8 is now available for download.


... for more information.

The installer package includes a Project Builder project template for  
easily creating new Cocoa-Python projects and a slew of examples.   
Alternatively, the developer can choose to develop applications without  
using Apple's developer tools. Full support for Interface Builder  
documents is included.

The PyObjC Python module provides a feature complete bridge between the  
Python programming language and Objective-C. With PyObjC, it is  
possible to transparently message Objective-C objects from Python and  
Python objects from Objective-C. Objective-C objects can be subclassed  
from within Python.  Support is also included for using the various  
functions, enumerated types, and global variables found throughout the  
Objective-C framework.

References to python dictionaries pass into Objective-C act like a well  
behaved member of the NSDictionary class cluster. Likewise, Python List  
references behave like a member of the NSArray class cluster.
Strings are transparently converted to the native type.  NSArray and  
NSDictionary references passed into Python behave like native Python  
lists and dictionaries; including the ability to enumerate either using  
the 'in' operator and to slice NSArray and NSMutableArray instances.

PyObjC fully supports creating full featured Cocoa applications written  
in pure Python.  There are aspects of PyObjC that are more powerful  
than Cocoa in pure Obj-C (the ability to automatically define  
classes/outlets based on the contents of a NIB file, for example).

PyObjC requires OS X 10.2 or greater.  10.1 support is possible and  
will likely happen soon-- contact me if you need 10.1 support and are  
willing to do a bit of grunt work to generate the appropriate files  
(easy to do-- just need a 10.1 development machine).

The installer package is designed to work with the built-in Python  
provided in OS X 10.2.   Source is included on the disk image and the  
pyobjc module works with Python 2.2 or greater as installed directly  
from the Python Source, with the MacPython packages, and with the Fink  
build of python.

PyObjC also provides an awesome environment for exploring frameworks.    
The following transcript was copied out of a Terminal window-- it is an  
example of working directly with the Objective-C runtime from Python  
within the terminal.

 >>> from objc import *
 >>> from Foundation import *
 >>> b =  
 >>> b.principalClass()
<objective-c class PBXProducerTarget at 0xa9030034>
 >>> NSBundle.searchPathsForSupportFilesWithSubpath_("FooBar")
     "/Volumes/Data/Users/bbum/Developer/ProjectBuilder Extras/FooBar",
     "/Network/Developer/ProjectBuilder Extras/FooBar",
     "/Developer/ProjectBuilder Extras/FooBar"
 >>> PBXProject = lookUpClass("PBXProject")
 >>> p =  
 >>> p.targets()
 >>> p.buildStyles()

The version # of 0.8 indicates that documentation is lacking, unit  
tests are incomplete and there may be a bug or two lurking within.  In  
practice, the module has proven to be very stable and to allow for the  
development of extremely complex Cocoa projects in pure Python or a mix  
of Python and Objective-C.