Re: [Pyobjc-dev] Supporting (NSString **) API (and the like)
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2002-11-26 23:48:57
|
Definitely an improvement, but raises another question.... what to do if the method returns BOOL, but we want it to return a tuple like thing. For example, consider: >>> app, docType = NSWorkspace.sharedWorkspace().pyobjcGetInfoForFile_("/tmp/opt5_faq.pdf") >>> print app /Applications/Preview.app >>> print docType pdf But: >>> app, docType = NSWorkspace.sharedWorkspace().pyobjcGetInfoForFile_("/tmp/something that isn't there") 2002-11-26 18:47:05.074 python[23743] LSGetApplicationForURL() returned -43 for file /tmp/something that isn't there. Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: unpack non-sequence This is because the current implementation returns nil -- not (nil, nil). There isn't really a way for it to return (nil, nil). A possible answer is to raise FileError -- but this fairly radically changes the behavior of the underlying API. Are there examples from within the python library of things that return a tuple vs. None?? Hmmm..... b.bum |