Table Of Contents

Previous topic

SMap

Next topic

Heterogeneous Relation Graphs

SList

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).

class speect.SList

A list class, an abstract data structure that implements an ordered collection of value, where the same value may occur more than once.

Note

The SList object inherits from SObject in the Speect Engine and can therefore be used in functions/methods that require parameters of type SObject.

Operations

SList supports the following Python list operations:

len(l)

Return the number of items in the list l.

l[index]

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.

del l[index]

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.

str(l)

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.

Functions

SList.value_get()

value_get(index)

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:

list[index]

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:

list.value_get(index)

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.
Return type:SObject
Note :Indexing starts from 0.