[Pythonmac-SIG] PyObjC quick start guide

Vrai Stacey pythonmac.sig at vrai.net
Sat Jan 5 22:39:21 CET 2008


Hi,

I've been playing around with PyObjC (the default version that ships with 
Leopard) but have hit a bit of a dead end. Does anyone know of a good guide 
to PyObjC that's aimed at experienced Python coders? I've found plenty of 
guides that are just step-by-step tutorials for building Cocoa applications, 
but these are far too simplistic to be of any use. What I'm after is 
something that explains how different types of method are called, the 
underlying Python structure of ObjC objects and *exactly* how/where PyObjC 
objects differ from vanilla Python objects.

Obviously the differences occur because Objective C uses a different OO idiom 
to Python and so the bridged APIs don't 'fit' as well as ones written in 
(say) C++ would. However all the examples and tutorials I've been through get 
bogged down in "implement trivial application X" details and never go in to 
enough depth about *how* Python is wrapping the underlying objects.

Specifically, I'm looking for documentation that can help me understand 
features like class method support.

Take IOBluetooth.IOBluetoothDeviceInquiry for example. The documentation in 
XCode states that this class has a factory method inquiryWithDelegate, which 
you would use in Objective C as ...

SomeDelegate * delegate;
// ... instantiate delegate ...
IOBluetoothDeviceInquiry * inquiry;
inquiry = [IOBluetoothDeviceInquiry inquiryWithDelegate: delegate];
// ... handle null ...
IOReturn retVal = [inquiry start];

Now in Python I'd expect that would translate to ...

// ... import IOBluetooth bundle ...
delegate = new SomeDelegate ( )
inquiry = IOBluetooth.IOBluetoothDeviceInquiry.inquiryWithDelegate_ \
	  ( delegate )
retVal = inquiry.start ( )

However there seems to be no sign of the class method. Instance methods are 
still present (e.g. initWithDelegate_) but not the class ones. Obviously they 
are there somewhere, but I've yet to find them and am somewhat frustrated 
that the tutorials I've found don't seem to cover the area (once I've figured 
it out I'll have to write my own :).

Any pointers towards documentation would be greatly appreciated,

vrai.


More information about the Pythonmac-SIG mailing list