Re: [Pyobjc-dev] Article on MacDevCenter
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2003-02-01 18:54:40
|
On Saturday, Feb 1, 2003, at 13:37 US/Eastern, Dinu Gherman wrote: >> http://www.macdevcenter.com/pub/a/mac/2003/01/31/pyobjc_one.html > > Nice and a good move! All I have to "criticize" is that there is not > quite enough of an emphasis on mutable vs. unmutable objects, both > in Python and the Foundation framework (Tuples/Lists vs. NSArray/ > NSMutableArray, say) and the PyObjC bridging between them. Or is > that no issue at all? Definitely an issue -- but the bridge "handles" it in the same fashion that ObjC "handles" it: >>> a = NSArray.arrayWithArray_([1,2,3,4,5]) >>> a <NSCFArray objective-c instance 0x50290> >>> a[0] = 5 Traceback (most recent call last): File "<stdin>", line 1, in ? File "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/objc/_convenience.py", line 173, in <lambda> ('__setitem__', lambda self, index, anObject: self.replaceObjectAtIndex_withObject_(index, anObject)), objc.error: NSInternalInconsistencyException - *** -[NSCFArray replaceObjectAtIndex:withObject:]: mutating method sent to immutable object If you need a mutable array, you can create one in a couple of different ways: >>> a = a.mutableCopy() >>> a[0] = 5 >>> from Foundation import Conversion >>> x = Conversion.pythonCollectionFromPropertyList(a) Well, that last one *will* work after I fix a bug in the Conversion module. :-) > I'm curious for the next parts! Any hints on when to expect them? After 0.9... The next article will discuss the construction of a trimmed down version of Web Services Tool -- WST without the dynamic toolbar, basically. A good example as it nicely demonstrates how to build a multi-window style app [actually -- I *could* do it as a multi-doc app example] that leverages the incredible ease with which Python can communicate to XML-RPC servers. b.bum |