[Pythonmac-SIG] newbie questions about Mac APIs in Python

Joe Strout joe at strout.net
Wed Oct 15 00:06:56 CEST 2008


On Oct 14, 2008, at 3:58 PM, Joe Strout wrote:

> OK, I'm fine with (and used to, from other environments) those sorts  
> of limitations.  So in Python, how would you go about accessing  
> those things?  Just import objc and make the same calls you would in  
> a real PyObjC app?


Just to show I'm making an effort... here's code that works fine in a  
PyObjC app, but doesn't seem to be working in interactive mode:

 >> import objc
 >>> from Foundation import *
 >>> synth = NSSpeechSynthesizer.alloc().initWithVoice_(None)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'NSSpeechSynthesizer' is not defined

Poking around in Foundation, sure enough, NSSpeechSynthesizer isn't  
there.  A lot of other stuff is, like NSError, though.  Where should  
NSSpeechSynthesizer be imported from, and why don't I need any other  
imports in my PyObjC source file?

Thanks,
- Joe






More information about the Pythonmac-SIG mailing list