From: Michael C. <mi...@ku...> - 2009-11-29 10:12:17
|
On 29/11/2009 7:41 PM, James Teh wrote: > Why get this as a list and then iterate through it using index? getVoices returns an ISpeechTokens object. This object has a count method, which comtypes specifically supports in __len__. It also has an Item method, which comtypes supports with __getitem__. This means that getVoices() isn't returning a list of live voice objects, but just an object that could be indexed or iterated. If being iterated, a real live voice object will be provided for each loop. However if there is an error initializing that voice object, then the whole for loop will break. Where as if you fetch it by index inside, you can catch the exception. At least this is how I understand the situation. Mick |