[Pythonmac-SIG] hi, everybody!

Bob Ippolito bob at redivi.com
Tue Jan 6 12:49:59 EST 2004


On Jan 6, 2004, at 12:21 PM, Alex Martelli wrote:

>
> On Jan 5, 2004, at 1:58 PM, Bob Ippolito wrote:
>    ...
>> You should also take a good look at PyObjC ( http://pyobjc.sf.net/ ), 
>> which is the runtime bridge between Objective C and Python, that lets 
>> you rather seamlessly take advantage of just about any Objective C 
>> framework with the convenience of Python.  This means that you can 
>> write Python applications using Apple's flagship Cocoa UI framework, 
>> and even use Interface Builder to build the GUIs.
>
> I guess I should gain some passing acquaintance with Objective C for 
> the purpose...?  I did look at that language many, many years ago, 
> when Brad Cox's book came out (gosh, that must be TWENTY years ago... 
> oh my...!!!), but don't really remember all that much about it (it WAS 
> long ago, and I never really used the language at all, just studied 
> the book...).  Could you suggest some URL and/or book for the purpose? 
>  Or shd I just dive right into the "runtime bridge" without needing 
> any understanding of the language on one side of it...?

http://developer.apple.com/ and file:///Developer/Documentation/ should 
be sufficient.

Here are some quick tips:
  * Objective C is reference counting, but PyObjC does it all for you 
(yay!)
  * Objective C has a flat namespace for classes
  * Modules that define Objective C classes can NOT be unloaded, ever 
(modules as in bundles or dylibs).
  * You can not throw away classes, ever.
  * You can't replace classes, ever (but you can pose for them, put 
categories and override their methods, etc..  none of it is 
recommended).
  * ObjC methods are done with selectors that look like "foo:bar:" and 
are called like [obj foo:someFoo bar:someBar].  In PyObjC this turns 
into obj.foo_bar_(someFoo, someBar).  So learn how to translate between 
colons and underscores, de-interleave selectors and arguments, and 
never forget the trailing underscore.
  * ObjC has separate namespaces for class methods and instance methods, 
like metamethods and instance methods in Python (if you're using the 
PEAK way of metamethods, where you're allowed to have an instance 
method as well).
  * ObjC does not support multiple inheritance, but....
  * ObjC uses categories, which are like mixins except they happen after 
class creation.  They can not add new instance variables to the class, 
but can add or replace methods.
  * Watch out for ObjC selectors that use pointers to C structures and 
datatypes, the selectors might need to be tweaked (to specify whether 
the data is "in", "out", or "in-out"), or worst case some helper code 
may need to be written to aid PyObjC.  This is all mostly taken care of 
by PyObjC for Apple's frameworks.
  * You can subclass ObjC from Python, just do it like you normally 
would.  You can mixin Python classes, but still single inheritance from 
ObjC.

That's all I can think of at the moment.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20040106/1b79fada/smime.bin


More information about the Pythonmac-SIG mailing list