SList containers are the Speect Engine equivalent of the Python list type. The Python SList class is just an interface to the Speect Engine C SList type. Python SList objects can not be instantiated, however, it can be a return value of certain functions or class attributes (for example SVoice.dataObjects).
A list class, an abstract data structure that implements an ordered collection of value, where the same value may occur more than once.
The SList object inherits from SObject in the Speect Engine and can therefore be used in functions/methods that require parameters of type SObject.
SList supports the following Python list operations:
Return the number of items in the list l.
Return the item in the list that is associated with the given index, where index is the index of the item in the list. Indexing starts from 0. Raises a IndexError if index is out of bounds.
l[index] = value
Set l[index] to value, where index is an index to the list. Indexing starts from 0. Raises a IndexError if index is out of bounds.
Remove l[index] from l. Raises a IndexError if index is out of bounds. Indexing starts from 0.
for item in l
SList also supports the Python iterator protocol and therefore one can iterate over a list’s items.
SList supports the Python method __str__() and can therefore be used in the str() built-in function and by the print statement to compute the “informal” string representation of the list.
Get the raw SObject value in the list that is associated with the given index. This function can be used in place of the normal:
The reason for this is that the above will try to convert the returned value into a Python object if possible. Sometimes we want the value as a Speect object. So instead we can use this function:
which will return the value object as it is in Speect, i.e. an SObject.
|Parameters:||index (int) – The index of the value in the list to get.|
|Returns:||The value at the given index.|
|Note :||Indexing starts from 0.|